Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Well here are the problems. First, you can't chomp a filehandle. When you try, you will get the following compile-time error:

Can't modify <HANDLE> in chomp at mytest.pl line 8, near "<STDIN> ) " Execution of mytest.pl aborted due to compilation errors.

Let's assume for a minute that you can chomp a filehandle. You're seeking to assign the return value of chomp, which will return the number of input record separators it chomped, not the target string. So if it could compile, it would return 1 (assuming there's a newline at the end of the target line).

Let's assume that you fixed all that and managed to put 293F into $start, and 2945 into $end. You still have the problem that the .. range operator can only expand ranges composed of non-empty strings that match /^[a-zA-Z]*[0-9]*\z/. So you don't get any auto-incrementing behavior. Your code:

@array = ( $start .. $end );

Attempts to use the range operator on a string that is incompatible with its wiring. According to perlop, if the string doesn't match /^[a-zA-Z]*[0-9]*\z/, then only the left operand will be returned. So after we fix the issues in line that chomps a filehandle and returns '1' to split, we're still left with the fact that the range operator won't even work here.

The simplest solution is to convert those hex strings into numeric values, perform the range expansion, and then convert the expanded range back to a hex representation.


Dave


In reply to Re^4: Extracting full digits from a range by davido
in thread Extracting full digits from a range by smw6181

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [Happy-the-monk]: Discipulus: are there any perl monks in Milano?
    [Discipulus]: i the moment likely no
    [karlgoethebier]: i wonder now it will be with my glasses.
    [Discipulus]: Milan Perl Mongers seems frozen at 2009
    [Discipulus]: karl you dont shoot with eyes, you shoot with the soul
    [jkva]: Reminds me of Guardians of the Galaxy
    [erix]: OT++: /me came across an osprey (=visarend (=Fischadler)) just now
    [erix]: (osprey are pretty rare in NL)

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (9)
    As of 2017-10-20 10:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My fridge is mostly full of:

















      Results (260 votes). Check out past polls.

      Notices?