Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Converting a list of numbers to use a range operator

by AnomalousMonk (Archbishop)
on Mar 24, 2013 at 00:28 UTC ( [id://1025100]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    >perl -wMstrict -le
    "use feature 'state';
    ...
    '2,3,5,6,7,9,11,12,13,14,16,17,19'
    
    '2,3,5-7,9,11-14,16,17,19'
    
  2. or download this
    $s =~ s{
      (?<! \d) ($n)   (?{   order($^N) })
      (?: $sep ($n) (?(?{ ! order($^N) }) (*F))){2,}
      }
      {$1-$2}xmsg;
    
  3. or download this
    sub order {
      state $p = 0;
    ...
      (?: $sep ($n)  (?(?{ ! order() }) (*F))){2,}
      }
      {-$^N}xmsg;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-25 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found