Hi add this line before your code
$/ = "\n";
What this does is breaks your file reading sequence at every new line so
that each new line is stored as a separate item in the array  you are using.

Lemme know if this helps or doesn't.

On 10/19/06, Gerald Host <[EMAIL PROTECTED]> wrote:

I tried both, and they typically do work for me, but right now they just
aren't...

QQQ line1....
line2
line3
...
lineX QQQ

any ideas?

Ryan

On 10/19/06, Helliwell, Kim <[EMAIL PROTECTED]> wrote:
>
> Another way:
>
> foreach $line (<IN>)
> {
> ...
> }
>
> if you don't want to slurp all the lines into an array (to save memory).
>
> Kim Helliwell
> LSI Logic Corporation
> Work: 408 433 8475
> Cell: 408 832 5365
> [EMAIL PROTECTED]
>
> Please Note: My email address will change to [EMAIL PROTECTED] on
> Oct 14. The old 'lsil.com' email address will stop working after Jan 15,
> 2007. Please update your address book and distribution lists
> accordingly. Thank you.
>
> -----Original Message-----
> From: Gerald Host [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 19, 2006 3:35 PM
> To: Perl List
> Subject: reading a file
>
> I'm trying to read a text file line-by-line.
>
>                     open IN, shift;
>                     my @lines=split("\n",<IN>);
>                     foreach my $line (@lines) {
>                             print OUT "QQQ $line QQQ\n";
>                             }
>
> The problem is that it always gives me the entire file, not line by
> line.
> What did I do wrong?  Other things I've tried:
>
>                 open IN, shift;
>                 while (my $line =<IN>) {
>                             print OUT "QQQ $line QQQ\n";
>                             }
>
>
> Ryan
>


Reply via email to