in reply to Re: Regex and writing lines in file
in thread Regex and writing lines in file
I opened the file in string context and was able to find the pattern successfully. But I could not substitute the matched pattern with required pattern
$extra = "This is i will place after match\n.an this too"; open (my $fh, '+<', $file); $data = <$fh>; $data = s/(.*entry)\n([^\n]*)\n/$1\n$extra/
The $1 is found successfully. But could not do the substitution in the file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex and writing lines in file
by Random_Walk (Prior) on May 01, 2013 at 11:38 UTC | |
by amma (Novice) on May 01, 2013 at 17:55 UTC |