in reply to Re^3: push to an array lines matching a pattern, and the lines before and after the matching
in thread push to an array lines matching a pattern, and the lines before and after the matching
use 5.014; use warnings; use Time::HiRes qw(usleep ualarm gettimeofday tv_interval); my @array; my $pattern = '\bsala|che|relazione|di|questo|coso|^qui\$'; open( my $filehandle, "<textMatchInAfile.txt" ); my $time = [gettimeofday]; while (<$filehandle>) { if ( $_ =~ /$pattern/ ) { push @array; } } say 'time while' . tv_interval($time);
|
|---|