in reply to Regex and writing lines in file
Output#!/usr/bin/perl use strict; use warnings; my $file; my $match = "that"; my $extra = "Hello, I snook in here\nme too!"; { local $/; $file = <DATA>; $file =~ s/$match\n([^\n]*)\n([^\n]*)/$match\n$1\n$2\n$extra/; } print $file; __DATA__ this that leave me leave me move me and me
this that leave me leave me Hello, I snook in here me too! move me and me
Cheers,
R.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex and writing lines in file
by amma (Novice) on May 01, 2013 at 09:59 UTC | |
by Random_Walk (Prior) on May 01, 2013 at 11:38 UTC | |
by amma (Novice) on May 01, 2013 at 17:55 UTC |