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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.