Jonathan has asked for the wisdom of the Perl Monks concerning the following question:
I want to look in each line for the string but don't like spliting on new line then adding them back with the map line.my $tsv_data; # Slurp the file { local $/ = undef; local *BIGFILE; open BIGFILE, "<$tsv_data" or die "can't open big file. $!"; $tsv_data = <BIGFILE>; close BIGFILE or die "Can't close big file: $!"; } # Throw it all in an array for testing my @records = split /\n/, $tsv_data; # Opps need the line feeds back again for the output files @records = map { "$_\n" } @records; my @london = grep /LONDON/, @records; # Write to new file, amend old file.. ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Processing slurped file.
by Masem (Monsignor) on Sep 18, 2001 at 17:17 UTC | |
by Jonathan (Curate) on Sep 18, 2001 at 19:39 UTC | |
|
Re: Processing slurped file.
by dragonchild (Archbishop) on Sep 18, 2001 at 17:12 UTC | |
|
Re: Processing slurped file.
by Caillte (Friar) on Sep 18, 2001 at 17:32 UTC | |
|
Re: Processing slurped file.
by arturo (Vicar) on Sep 18, 2001 at 18:40 UTC | |
|
Re: Processing slurped file.
by petdance (Parson) on Sep 19, 2001 at 00:02 UTC | |
|
Re: Processing slurped file.
by broquaint (Abbot) on Sep 18, 2001 at 17:35 UTC |