Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Extracting full digits from a range

by bart (Canon)
on Aug 03, 2012 at 18:44 UTC ( #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;

Comment on Re: Extracting full digits from a range
Select or Download Code
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

      Yeah, I printed the wrong list.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2015-11-26 05:41 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (696 votes), past polls