in reply to Array size too big?
Hi, did you read through all of perlintro as you were advised earlier?
Here's how to read a file and print it line by line, as explained in more detail in perlop - IO Operators:
use strict; use warnings; my $file_in = "C:/Users/Joe/Documents/Genealogy/birdt.ged"; open my $FILE, "<", $file_in or die "could not open $file_in $!"; while ( my $line = <$FILE> ) { print "$. $line"; } close $FILE or die "could not close $file_in $!"; __END__
Although I would rather use the convenience of a filehandling module like Path::Tiny :
use strict; use warnings; use Path::Tiny; # imports path() my $file_in = "C:/Users/Joe/Documents/Genealogy/birdt.ged"; my $line_num = 0; for my $line ( path( $file_in )->lines ) { print sprintf '%4d %s', ++$line_num, $line; } __END__
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array size too big?
by JillB (Novice) on Nov 19, 2017 at 23:59 UTC | |
by haukex (Archbishop) on Nov 20, 2017 at 09:10 UTC | |
by 1nickt (Canon) on Nov 20, 2017 at 00:40 UTC |