in reply to File Reading and Closing confusion
As far as the code $text = <FILE> goes, look at the difference
In the abscence of a code example, these links may get you started. Basically, you can read a file line by line(default behavior), or sysread it in chunks. The diamond operator <> adds some magic. See diamond operator and "perldoc -f read"#!/usr/bin/perl use warnings; use strict; open (FILE,"< $0 ") or die "Couldn't open: $!"; # check the difference between these two lines my $text = do {local $/; <FILE>}; #my $text = <FILE>; close FILE; print "$text\n";
Some filehandles you cannot seek on, like a socket filehandle. See read and sysread and run "perldoc -q file" and read all the sections. Remember, if you are on a unix style OS, you have file descriptors associated with each filehandle in /proc/$pid/fd. See How to close all open file descriptors after a fork? and close filehandles Remember, the file descriptors (numbers) in /proc/$pid/fd/ is where the real action takes place( at least on linux).... the filehandles are just convenience handles.
Alot of us Perl hackers are lazy, and don't close filehandles after use, just letting the system clean them up when the program exits. :-)
The one common gotcha encountered with the mix of unix and win32 systems, is that the 2 system have different line endings, so when the default line-by-line reading behavior is used to read a windows file on linux, proper line reading can get broken. Read "perldoc -f binmode".