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
Post a Comment