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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -