- or download this
open (FILE, "foo.txt");
my @lines = <FILE>;
close FILE;
- or download this
open (FILE, "foo.txt");
my @words = map { split } <FILE>;
close FILE;
- or download this
my @words = map { split(' ', $_) } <FILE>;
- or download this
s/[.,!\?]\B//g
- or download this
open (FILE, "foo.txt");
my @words = map { s/[.,!\?]\B//g; split; } <FILE>;
close FILE;
- or download this
open (FILE, "foo.txt");
my @lines = map { s/[.,!\?]\B//g } <FILE>;
close FILE;
- or download this
open (FILE, "foo.txt");
my @lines = map { s/[.,!\?]\B//g; $_; } <FILE>;
close FILE;
- or download this
open (FILE, "foo.txt");
my @lines = map { chomp; $_; } <FILE>;
close FILE;
- or download this
open (FILE, "foo.txt");
my @lines = <FILE>;
chomp(@lines);
close FILE;
- or download this
Benchmark: timing 100 iterations of chomp, map...
chomp: 31 wallclock secs (29.17 usr + 0.54 sys = 29.71 CPU)
map: 37 wallclock secs (34.63 usr + 0.59 sys = 35.22 CPU)