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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -