Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Extracting full digits from a range

by bart (Canon)
on Aug 03, 2012 at 18:44 UTC ( [id://985308]=note: print w/replies, xml ) Need Help??


in reply to Extracting full digits from a range

You have to
  1. get the start and end values,
    my($min, $max) = /\b([0-9a-f]+):([0-9a-f]+)\b/i;
  2. convert them to integers
    foreach($min, $max) { $_ = hex($_); }
  3. turn them into a range or span:
    my @list = $min .. $max;
  4. turn each into a hex number.
    my @hex = map { sprintf '%X', $_ } $min .. $max;
    will do.
  5. print out the list with ',' between them:
    $, = ','; print @list;
    update Oops, that should have been
    $, = ','; print @hex;

Replies are listed 'Best First'.
Re^2: Extracting full digits from a range
by cztmonk (Monk) on Aug 04, 2012 at 10:42 UTC

    Did you test? It outputs

    10559,10560,10561,10562,10563,10564,10565
      Yeah, I printed the wrong list.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-24 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found