You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
513 B
37 lines
513 B
14 years ago
|
#!/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)]);
|
||
|
|
||
|
|
||
14 years ago
|
open(my $fh2, '<', 'foo.txt');
|
||
14 years ago
|
|
||
14 years ago
|
while(my $line = <$fh2>) {
|
||
14 years ago
|
print $line;
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
my $fh3 = IO::File->new('foo.txt', 'r');
|
||
14 years ago
|
|
||
14 years ago
|
while(my $line = $fh3->getline()) {
|
||
14 years ago
|
print $line;
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
my $fh4 = IO::File->new('foo.txt', 'r');
|
||
|
my @lines4 = $fh4->getlines();
|
||
14 years ago
|
|
||
14 years ago
|
print @lines4;
|
||
|
print Data::Dumper->Dump([\@lines4], [qw(lines)]);
|
||
14 years ago
|
|
||
|
|
||
|
1;
|
||
|
__END__
|