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 -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -