playing with file handles

cat-town
Dan Buch 14 years ago
parent 760ded693b
commit d690d1b0bd

@ -0,0 +1,36 @@
#!/usr/bin/env perl
use strict;
use warnings;
use IO::File;
use Data::Dumper;
open(my $fh, '<', 'foo.txt');
my @lines = <$fh>;
print Data::Dumper->Dump([\@lines], [qw(lines)]);
open(my $fh, '<', 'foo.txt');
while(my $line = <$fh>) {
print $line;
}
my $fh = IO::File->new('foo.txt', 'r');
while(my $line = $fh->getline()) {
print $line;
}
my $fh = IO::File->new('foo.txt', 'r');
my @lines = $fh->getlines();
print @lines;
print Data::Dumper->Dump([\@lines], [qw(lines)]);
1;
__END__

@ -0,0 +1,6 @@
these
runes
are
dusty
sir
?
Loading…
Cancel
Save