X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FFileHandle.pm;h=6b3636a089d5ea59d6757564f230b4d961908177;hb=a79d563c5b1e534968f5274b3cc36fa26e10ba16;hp=eec9b61f31bbd296d85b9d4c8bf72b8d4a76bff5;hpb=f4dad39ef1a76c1f6bbf6733d7c2ee209381be78;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/FileHandle.pm b/lib/FileHandle.pm index eec9b61..6b3636a 100644 --- a/lib/FileHandle.pm +++ b/lib/FileHandle.pm @@ -1,10 +1,10 @@ package FileHandle; -use 5.003_11; +use 5.006; use strict; -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); +our($VERSION, @ISA, @EXPORT, @EXPORT_OK); -$VERSION = "2.00"; +$VERSION = "2.02"; require IO::File; @ISA = qw(IO::File); @@ -111,25 +111,25 @@ FileHandle - supply object methods for filehandles use FileHandle; - $fh = new FileHandle; + $fh = FileHandle->new; if ($fh->open("< file")) { print <$fh>; $fh->close; } - $fh = new FileHandle "> FOO"; + $fh = FileHandle->new("> FOO"); if (defined $fh) { print $fh "bar\n"; $fh->close; } - $fh = new FileHandle "file", "r"; + $fh = FileHandle->new("file", "r"); if (defined $fh) { print <$fh>; undef $fh; # automatically closes the file } - $fh = new FileHandle "file", O_WRONLY|O_APPEND; + $fh = FileHandle->new("file", O_WRONLY|O_APPEND); if (defined $fh) { print $fh "corge\n"; undef $fh; # automatically closes the file @@ -225,7 +225,7 @@ supported C methods: Furthermore, for doing normal I/O you might need these: -=over +=over 4 =item $fh->print @@ -238,12 +238,12 @@ See L. =item $fh->getline This works like <$fh> described in L -except that it's more readable and can be safely called in an -array context but still returns just one line. +except that it's more readable and can be safely called in a +list context but still returns just one line. =item $fh->getlines -This works like <$fh> when called in an array context to +This works like <$fh> when called in a list context to read all the remaining lines in a file, except that it's more readable. It will also croak() if accidentally called in a scalar context.