Tom Tromey wrote:
"Akim" == Akim Demaille [EMAIL PROTECTED] writes:
Akim Six, six for them! (I'm not counting those for file handles,
Akim which perl refuses as my, not sure to understand why).
The way file handles work is another reason to dislike Perl. At
least, I've always found them confusing.
The Perl5 file handles are different. This example is for reading a file.
Really, the arguments to "new" are the same arguments open accepted.:
require 5.004;
use IO::File;
my $fh = new IO::File " filetoread";
while ($fh-getline)
{
dostuff $_;
}
The other functions available for old style file handles are similar. These
are just front ends for the old Perl builtins, but context switching just
happens automatically now. e.g. $fh-eof, $fh-print, $fh-open (usually
called implicitly with arguments to new), $fh-close (unnecessary - "undef
$fh" will autoclose), $fh-autoflush, $fh-fileno, etc.
"$fh-getlines;" will work like calling $fh in an array context.
"my $line = $fh-getline;" "my @lines = $fh-getlines;" (to read an entire
file) are valid constructs. I don't remember if the same was true of , but
I think so.
P.S. You probably won't need to know, but Perl5 prior to 5.004 used
FileHandle in lieu of IO::File, and FileHandle is still supported as a front
end for IO::File, but is deprecated.
Derek
--
Derek Price CVS Solutions Architect ( http://CVSHome.org )
mailto:[EMAIL PROTECTED] OpenAvenue ( http://OpenAvenue.com )
--
As honest as the day is long.
- S. Z. Sakall as Headwaiter Carl, _Casablanca_