go ahead... be a heretic | |
PerlMonks |
Re: Reading from a fileby castaway (Parson) |
on Aug 26, 2003 at 10:01 UTC ( [id://286642]=note: print w/replies, xml ) | Need Help?? |
There are a couple of possible mistakes: 1. You don't check if the open() worked, and you're not passing it a full pathname to the file, are you sure it's found the file? Try using: - the code will end (die) if the file cant be found or opened, including the '$!' will give you the system error message, such as 'cant find file' etc. 2. You're using file1, whether the open actually worked or not. To get Perl to tell you if the file handle is actually readable, try putting 'use warnings;' at the top of your code. Do you realise that you are trying to print the first line of the file, then assign the second line to $line1, and then print that? Each line is read only once from the file handle, the next access will get the following line.. C.
In Section
Seekers of Perl Wisdom
|
|