|
|
| Perl-Sensitive Sunglasses | |
| PerlMonks |
Re: Regex problem while parsing tagged, hierarchical databy mk. (Friar) |
| on Sep 12, 2006 at 11:10 UTC ( [id://572556]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
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
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||