Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

    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
Node Status?
node history
Node Type: note [id://985308]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2015-07-31 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls