Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: sequential substitutions

by Anonymous Monk
on Aug 04, 2018 at 15:22 UTC ( [id://1219855]=note: print w/replies, xml ) Need Help??


in reply to sequential substitutions

$text = '<foo>3</foo><foo>14</foo><foo>159</foo>'; while($text =~ /<foo>(.*?)<\/foo>/g) { push (@la,$1); }; sort @la; foreach(@la) { print "<foo>$_<\/foo>\n"; }

Replies are listed 'Best First'.
Re^2: sequential substitutions
by haukex (Archbishop) on Aug 05, 2018 at 21:08 UTC

    Sorry, but there are at least two things wrong with that code (aside from using regexes to parse HTML...): It does not re-number the entries as the OP specified, and sort @la; does nothing (should be @la = sort @la; instead, warnings would have told you about this). So really the only effect of this code is to remove any non-<foo> tags from the input and re-format it slightly.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1219855]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-20 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found