in reply to Perl script to read from a text file
my $infile = "filename.dat"; my @records; { open my $fh , "<", $infile or die "Can't open $infile!\n$!"; my @records = map { chomp; [ split /\t/ ] } <$fh>; } { local $" = "\t"; print "@{$_}\n" foreach @records; }
Each record is held in an anonymous array, referenced by the top level array, @records.
Update: Be sure that if you turn this in as homework you've studied the idioms so that you can explain them. There's a good chance your professor hasn't yet covered everything I (intentionally) used in this example.
Dave
|
|---|