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-5555
"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]