in reply to Re: file handling
in thread file handling

using IO::File
use IO::File; my $fh = IO::File->new( 'foobar.txt', 'r' ); while ( my $line = $fh->readline ) { print $line if $fh->input_line_number > 3; }


Evan Carroll
I hack for the ladies.
www.EvanCarroll.com

Replies are listed 'Best First'.
Re^3: file handling
by toolic (Bishop) on Jul 09, 2008 at 18:10 UTC
    I like the different approach. But, I can not get your example to work. I get this error:
    Can't locate object method "readline" via package "IO::File"

    Admittedly, I am running an older version of perl (5.8.5 on linux), but if I look at the docs for the more recent versions of perl (5.8.8 and 5.10.0) for the IO::File core module, they also do not mention a "readline" method. Does your code actually run for you? Just curious.

      That's because the method is called getline. :)

      while ( my $line = $fh->getline ) {
        That needs to be
        while ( defined( my $line = $fh->getline ) ) {

        defined is automatically added in some cases. That's not one of them.