in reply to Insert lines into specific stanza line
It took me three or four minutes to figure out what your for loop does, and I still have no idea what it has to do with the stated problem. I think I would try a different approach altogether...
open INPUT, '<', 'inputfile'; open OUTPUT, '>', 'resultsfile'; local $/ = "</stanza>"; while (<INPUT>) { my $stanza = $_; if ($stanza =~ /<stanza/) { my ($dottedquad) = $stanza =~ /<stanza\s*(\d+[.]\d+[.]\d+[.]\d+)\s*>/; $stanza .= " sl3 yet another line\n"; # Make other changes to $stanza here as desired. print OUTPUT $stanza . $/; }}
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Insert lines into specific stanza line
by oko1 (Deacon) on Aug 13, 2010 at 19:34 UTC |
In Section
Seekers of Perl Wisdom