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]