in reply to Re^2: Way to remove the new line characters at the end of the content in a file
in thread Way to remove the new line characters at the end of the content in a file
As the anonymous monk says, $MYFILE and MYFILE are two different things. You're opening your file with:
open( MYFILE, "E:/Temp/INYROHS/serverlist.txt") or die "Can't open '$s +erverlist': $!";
Using this method, you have to use MYFILE to read from the file, not $MYFILE. My code uses $FH because current practice in perl is to open files like this:
open my $MYFILE, '<', "E:/Temp/INYROHS/serverlist.txt" or die "Can't o +pen '$serverlist': $!";
There are several advantages to this method: It's easier to pass file handles to subroutines when you use lexical variables. Files will automatically close for you when they go out of scope (i.e. you get to the closing '}' of the block containing the definition.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|