-----Original Message-----
From: Luba Pardo [mailto:[EMAIL PROTECTED]
Sent: Friday, October 13, 2006 6:27 PM
To: beginners@perl.org
Subject: consecutive lines in a file
Dear sir/madam:
I am trying to write a script to process to consecutive lines at a time and
compare elements of between two consecutive lines.
I tried something like:
$i=0;
while (<IN>){
chomp;
@a1_s= split/\</, $_{$I];
@a2_s= split/\</,$_[$i+1];
if ($a1_s[1] =~ /HG-Stats_gi1/){
@temp = split/>/, $a1_s[1];
@temp1 = split/>/, $a2_s[1];
print " line is $i, array is @a1_s, array 2 es @a2_s\n";
}
$i++;
}
close IN;
but it does not work. I guess the $_[$i] and $_[$i+1] does not work, but I
do not exactly how.
Could anyone give any idea why?
Thanks in advance
while (<IN>){ will read only line by line.
so try doing
@linesarray = <IN>;
for($i=0; $i < @linesarray; ;$i+=) {
@a1_s= split/\</, $linesarray{$i];
@a2_s= split/\</, $linesarray[$i+1];
.....
.....
}
"Legal Disclaimer: This electronic message and all contents contain information
from Cybage Software Private Limited which may be privileged, confidential, or
otherwise protected from disclosure. The information is intended to be for the
addressee(s) only. If you are not an addressee, any disclosure, copy,
distribution, or use of the contents of this message is strictly prohibited. If
you have received this electronic message in error please notify the sender by
reply e-mail to and destroy the original message and all copies. Cybage has
taken every reasonable precaution to minimize the risk of malicious content in
the mail, but is not liable for any damage you may sustain as a result of any
malicious content in this e-mail. You should carry out your own malicious
content checks before opening the e-mail or attachment."
www.cybage.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>