Luba Pardo am Freitag, 20. Oktober 2006 14:16:
> Dear all,

Hello

> I am trying to write a script that reads in two or three consecutive lines
> to process those. For example that if the first line of file_1 match with
> an scalar from a file_2, then print the lines 2 and 3 of the file_1. I
> tried to save everything in a array, but the file is extremely large and it
> kicks me out.
>
> So, I have tried to work line by line:

You miss

  use strict;
  use warnings;

and the handling of the errors/warnings that would show up (declare variables 
with my etc.).

Without these, its very easy to write messy code that won't do what you want.

> open (READER_1,"out2222") || die "\n I can't open the file READER_1 !!\n";
> open (READER_2,"out.txt") || die "\n I can't open the file READER_2 !!\n";

Include $! in the die string to get the reason when open failes.

> @a1= <READER_2>;

The contents of @a1 are never used, only its size.

> close (READER_2);
>
> @arr=();

Never used.

> for ($i=0; $i<=$#a1;$i=$i+1 ) {

Not clear to me what you want in this for loop:

>  $l= <READER_1>;

$l contains one line from READER_1.

>  @temp1=split/[<>]/,$l[$i];

There is no array @l that could be accessed with $l[$i].

>  @temp2=split/[<>]/,$l[$i+1];
>  @temp3=split/[<>]/,$l[$i+2];
>  @temp4=split/[<>]/,$l[$i+3];
>
>  print " @temp1 is temp1\n";
> }
>
> BUT I DO NOT GET ANYTHING. I wonder if there is another way to work it out.

Dani

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to