in reply to Regex problem while parsing tagged, hierarchical data
hope this helps:
perl -i -pe 'if (/<level1 id=\"(.*)\">/) {$currentid = $1;} elsif (/<level2>/) {s/<level2>/<level2 id="$currentid">/g}' input
edit: just deleting the redundant $_.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"one who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever."
mk at rio dot pm dot org
perl -i -pe 'if (/<level1 id=\"(.*)\">/) {$currentid = $1;} elsif (/<level2>/) {s/<level2>/<level2 id="$currentid">/g}' input
edit: just deleting the redundant $_.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"one who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever."
mk at rio dot pm dot org
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regex problem while parsing tagged, hierarchical data
by Mago (Parson) on Sep 19, 2006 at 11:25 UTC | |
by smokemachine (Hermit) on Sep 19, 2006 at 12:53 UTC | |
by Mago (Parson) on Sep 19, 2006 at 12:57 UTC | |
by smokemachine (Hermit) on Sep 19, 2006 at 13:14 UTC | |
by mk. (Friar) on Sep 19, 2006 at 13:57 UTC | |
|
In Section
Seekers of Perl Wisdom