Re: Why does this code fail? - Sorry here are the line numbers..

2002-12-17 Thread Satya_Devarakonda

my @str_start = qw ( 1 0 28 27 34 );
my @str_length = qw ( 8 9 10 9 2 );
my @search_key = qw (FILETYPE.ZIP RBZ RBZ Bytes Errors);
Since search_key is used in a regular expression it might be better to
create one.
my $search_key = qr/FILETYPE.ZIP|RBZ|RBZ|Bytes|Errors/;
But will qr execute search of regular expressions strings in that order?


open (MODEMLOG, /opt/cleo/envoy/log/calenvoy.$MonthDay ) or die
(Can
not open MODEMLOG);
You should include the $! variable in the error message so you know why
it failed.
Thank you - I will do that.



my @search_out =  qw( \@env_start  \@env_end  \@env_files
\@env_bytes \@env_errors );
Here You are using qw() so this is the same as:
my @search_out = ('\@env_start', '\@env_end', '\@env_files','
\@env_bytes', '\@env_errors');
for ($i = 0; $i  @search_key; $i++)
{
${search_out[$i]} = grep (/$search_key[$i]/,@modem_log);

You are assigning a list to a scalar here which is probably not what you
want.  Also, why you are overwriting the current values in the
@search_out array?
My intention was to use search_out[$i] as reference to an array that
contain outcome of a search using the grep command e.g. reference to start
times (env_start array) or  to end times (env_end) and soon. Is this usage
wrong???


for ($j = 0; $j  ${search_out[0]}; $j++)
{
${search_out[$i]} = substr ($search_out[$i][$j],$str_start
[$j].$str_length[$j]);
}
}

for ($i = 0; $i  @env_errors; $i++)
  ^^^
Where did this come from?
This was intended to be one of the arrays created by grep - ing the string
Errors from the Modem Log.


Thanks for your help - Satya




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Why does this code fail? - Sorry here are the line numbers..

2002-12-16 Thread Dave Storrs
On Sat, Dec 14, 2002 at 12:51:50PM -0500, [EMAIL PROTECTED] wrote:
 Can somebody tell what is wrong with this.
 
 I tried single quote (') in place of double quote() neither of them work.
 
 184 for ($i = 0; $i  @clm_types; $i++)
 185 {
 186@temp_str = grep (/$_/,@env_desc);
 187@fields = split (/,/,$temp_str[@temp_str - 1],4);
 188$env_final[$i] = join (/,/,$fields[1],$fields[2],@temp_str - 1);
 189  }
 
 /,/ should probably be written as , at loadstats1.pl line 188.


Unlike split, join() takes a string as its first argument, not a regex.  What you want 
is this:

$env_final[$i] = join (,,$fields[1],$fields[2],@temp_str - 1);
   
|
  Notice--no '/'s here

However, I'm not really sure that that's what you want either.  As
written, this line will join three elements into a string and assign
it to $env_findal[$i].  The three elements it will join are:

$fields[1]
$fields[2]
@temp_str - 1

The problem is that last one...I suspect that you want it to be the
last element of @temp_str, but what it is actually going to be is
the number that you get by subtracting 1 from the number of elements
in @temp_str.  Try this instead:

   $env_final[$i] = join(,,$fields[1],$fields[2],$temp_str[-1]);

--Dks

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Why does this code fail? - Sorry here are the line numbers..

2002-12-16 Thread Satya_Devarakonda

Thanks to all those guys who answered my question As you guys pointed out
the join worked without //s.

But the code also had some correction to be made (eg. line number 34) and
would look really like this(and not as I initially sent you folks).
There are still has some issues with line 11 and I am debugging it.

Sorry I am not very good at PERL but any suggestions to improve performance
are greatly  appreciated.

   my @str_start = qw ( 1 0 28 27 34 );
   my @str_length = qw ( 8 9 10 9 2 );

   my @search_key = qw (FILETYPE.ZIP RBZ RBZ Bytes Errors);
   my @search_out =  qw( \@env_start  \@env_end  \@env_files  \@env_bytes
   \@env_errors );
   #Open the Modem Log and get Start time, End time, File Information,
   Bytes received
   #Errors observed during dail up
   my $MonthDay = shift();
   print $Monthday;

   open (MODEMLOG, /opt/cleo/envoy/log/calenvoy.$MonthDay ) or die (Can
   not open MODEMLOG);
   my @modem_log = MODEMLOG;
   close (MODEMLOG ) or die ( Cannot close file: MODEMLOG);

   for ($i = 0; $i  @search_key; $i++)
   {
   ${search_out[$i]} = grep (/$search_key[$i]/,@modem_log);
   for ($j = 0; $j  ${search_out[0]}; $j++)
   {
   ${search_out[$i]} = substr ($search_out[$i][$j],$str_start
   [$j].$str_length[$j]);
   }
   }

   for ($i = 0; $i  @env_errors; $i++)
   {
   ${env_desc[$i]} = join (',',${env_files[$i]},${env_start[$i]},
   ${env_end[$i]}, ${env_bytes[$i]}, ${env_errors[$i]}, \n);
   }

   my @fields;
   my @clm_types = qw ( PHC.ZIP PMC.ZIP );
   for ($i = 0; $i  @clm_types; $i++)
   {
   @temp_str = grep (/${clm_types[$i]}/,@env_desc);
   @fields = split (/,/,$temp_str[@temp_str - 1],4);
   $env_final[$i] = join (',',$fields[1],$fields[2],@temp_str - 1);
   }

   } # End of the procModemLog()
###
Sincerely,
Satya Devarakonda
IS - EDI
Tufts Health Plan
Tel: 617-923-5587 X 3413
Fax: 617-923-



   

  Dave Storrs

  [EMAIL PROTECTED] To:  [EMAIL PROTECTED] 

  gpanda.com  cc: 

   Subject: Re: Why does this code 
fail? - Sorry here are the line numbers..   
  12/15/2002 02:25 PM  

   

   




On Sat, Dec 14, 2002 at 12:51:50PM -0500,
[EMAIL PROTECTED] wrote:
 Can somebody tell what is wrong with this.

 I tried single quote (') in place of double quote() neither of them
work.

 184 for ($i = 0; $i  @clm_types; $i++)
 185 {
 186@temp_str = grep (/$_/,@env_desc);
 187@fields = split (/,/,$temp_str[@temp_str - 1],4);
 188$env_final[$i] = join (/,/,$fields[1],$fields[2],@temp_str - 1);
 189  }

 /,/ should probably be written as , at loadstats1.pl line 188.


Unlike split, join() takes a string as its first argument, not a regex.
What you want is this:

 $env_final[$i] = join (,,$fields[1],$fields[2],@temp_str -
1);
  
|
  Notice--no '/'s here

However, I'm not really sure that that's what you want either.  As
written, this line will join three elements into a string and assign
it to $env_findal[$i].  The three elements it will join are:

 $fields[1]
 $fields[2]
 @temp_str - 1

The problem is that last one...I suspect that you want it to be the
last element of @temp_str, but what it is actually going to be is
the number that you get by subtracting 1 from the number of elements
in @temp_str.  Try this instead:

   $env_final[$i] = join(,,$fields[1],$fields[2],$temp_str[-1]);

--Dks

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]









-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Why does this code fail? - Sorry here are the line numbers..

2002-12-16 Thread John W. Krahn
Satya Devarakonda wrote:
 
 Thanks to all those guys who answered my question As you guys pointed out
 the join worked without //s.
 
 But the code also had some correction to be made (eg. line number 34) and
 would look really like this(and not as I initially sent you folks).
 There are still has some issues with line 11 and I am debugging it.
 
 Sorry I am not very good at PERL but any suggestions to improve performance
 are greatly  appreciated.
 
my @str_start = qw ( 1 0 28 27 34 );
my @str_length = qw ( 8 9 10 9 2 );
 
my @search_key = qw (FILETYPE.ZIP RBZ RBZ Bytes Errors);

Since search_key is used in a regular expression it might be better to
create one.

my $search_key = qr/FILETYPE.ZIP|RBZ|RBZ|Bytes|Errors/;


my @search_out =  qw( \@env_start  \@env_end  \@env_files  \@env_bytes 
\@env_errors );

You are using qw() so this is the same as:

my @search_out = ('\@env_start', '\@env_end', '\@env_files',
'\@env_bytes', '\@env_errors');


#Open the Modem Log and get Start time, End time, File Information,
Bytes received
#Errors observed during dail up
my $MonthDay = shift();
print $Monthday;
 
open (MODEMLOG, /opt/cleo/envoy/log/calenvoy.$MonthDay ) or die (Can
not open MODEMLOG);

You should include the $! variable in the error message so you know why
it failed.


my @modem_log = MODEMLOG;
close (MODEMLOG ) or die ( Cannot close file: MODEMLOG);
 
for ($i = 0; $i  @search_key; $i++)
{
${search_out[$i]} = grep (/$search_key[$i]/,@modem_log);

You are assigning a list to a scalar here which is probably not what you
want.  Also, why you are overwriting the current values in the
@search_out array?


for ($j = 0; $j  ${search_out[0]}; $j++)
{
${search_out[$i]} = substr ($search_out[$i][$j],$str_start
[$j].$str_length[$j]);
}
}
 
for ($i = 0; $i  @env_errors; $i++)
   ^^^
Where did this come from?


{
${env_desc[$i]} = join (',',${env_files[$i]},${env_start[$i]},
${env_end[$i]}, ${env_bytes[$i]}, ${env_errors[$i]}, \n);
}
 
my @fields;
my @clm_types = qw ( PHC.ZIP PMC.ZIP );

Again, why not just create a regular expression?

my $clm_types = qr/P[HM]C.ZIP/;


for ($i = 0; $i  @clm_types; $i++)
{
@temp_str = grep (/${clm_types[$i]}/,@env_desc);
@fields = split (/,/,$temp_str[@temp_str - 1],4);
$env_final[$i] = join (',',$fields[1],$fields[2],@temp_str - 1);
}
 
} # End of the procModemLog()
 ###



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Why does this code fail? - Sorry here are the line numbers..

2002-12-14 Thread Satya_Devarakonda
Can somebody tell what is wrong with this.

I tried single quote (') in place of double quote() neither of them work.

184 for ($i = 0; $i  @clm_types; $i++)
185 {
186@temp_str = grep (/$_/,@env_desc);
187@fields = split (/,/,$temp_str[@temp_str - 1],4);
188$env_final[$i] = join (/,/,$fields[1],$fields[2],@temp_str - 1);
189  }

/,/ should probably be written as , at loadstats1.pl line 188.

Satya Devarakonda
IS - EDI
Tufts Health Plan
Tel: 617-923-5587 X 3413
Fax: 617-923-





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]