pkt has asked for the wisdom of the Perl Monks concerning the following question:
Hello
I was tried to parse and order something like this
my $x = "<0>"; for (('<1>','<2>','<3>')) { $x =~ s/(<0>)/${1}${_}/; }
so i get this output:
<0> <3> <2> <1>
But i want to order from smaller to bigger
<0> <1> <2> <3>
how can i do to change it using regexp option, I was saw c modifier and \G, but i'm not sure how to use that
my $x = "<0>"; for (('<1>','<2>','<3>')) { if ($x =~ /<\d>/gc) { $x =~ s/(\G<\d>)/${1}${_}/g; } }
i was saw too pos function but it's a read only funcion or what's SCALAR mean in the documentation.
Thank a lot in advance
Nicolais
-----------------------------
Update: Basicaly i was tried to replace in the last match, how could i do that? using regexp only and of course it functions like pos, the best and good style way.
|
|---|