Try using:

my @lines = <IN>;

I don't think you need the split, and it's goofing things up.
I know the above works, because I use it all the time.

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

--
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