in reply to Slurping information and storing it in an array.
#!/usr/bin/env perl use warnings; use strict; print read_file('foo.txt'); exit; sub read_file { my $file = shift; open my $fh, '<', $file or die "Can not open file '$file' $!\n"; my @all_lines = <$fh>; close $fh; return @all_lines; }
If file "foo.txt" contains these 3 lines:
apple banana orange
then the script output will be:
You can then manipulate the array contents to suit your needs.apple banana orange
|
|---|