I want to add an element to array after matching pattern found using perl -


i've copied lines of file array , looping array pattern matching once pattern matches, want add lines same array , print in file.

my @lines = <file_in>; foreach $line (@lines){ if($line =~m/\s(\w*)_region\s/){ print $line; } 

i tried till pattern matching, , want add element after search.

open $ifile,'<:encoding(utf-8)', '/path/to/file.txt' || die $!; while (my $line = <$ifile>) {     chomp $line;     if ($line =~m/\s(\w*)_region\s/x) {         print $line     }    } close $ifile; 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -