On 10/13/06, Luba Pardo <[EMAIL PROTECTED]> wrote:
I am trying to write a script to process to consecutive lines at a time and compare elements of between two consecutive lines.
It might be easiest to read the file into an array. Of course, that's only practical if it's not a large file.
@a1_s= split/\</, $_{$I]; @a2_s= split/\</,$_[$i+1];
I can't see what you're trying to do. It looks as if you're trying to do something with the @_ array. Is that right? Or maybe you're hoping that those expressions on the right will evaluate as consecutive lines from the file? Here's some untested code showing one way of doing what you might be asking for: my $previous_line = ""; # or another dummy value while (<IN>) { chomp; my $current_line = $_; &handle_consecutive_lines($previous_line, $current_line); $previous_line = $current_line; } But maybe you want this untested code instead? my $flip = 0; my $previous_line = ""; while (<IN>) { chomp; $flip = not $flip; if ($flip) { $previous_line = $_; } else { my $current_line = $_; &handle_consecutive_lines($previous_line, $current_line); } } Either way, you can write a sub that will be called with two consecutive lines from the file; or you could replace the sub call with the actual code needed. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>