in reply to how to populate array with lines from text file?
in thread Answer: how to populate array with lines from text file?
1 #!/usr/bin/perl -w 2 use strict; 3 4 $file = "/path/file"; 5 @lines = (); 6 open (<FH>, "< $file") or die "Cannot open $file for read: $!"; 7 while (<FH>) { 8 chomp; 9 push (@lines, $_); 10 } 11 close FH or die "Cannot close $file: $!"; 12 13 print join(',', @lines); # now it works
|
|---|