Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Length of unpacked string for "hex" data

by SirBones (Friar)
on Apr 24, 2006 at 22:52 UTC ( #545423=note: print w/ replies, xml ) Need Help??


in reply to Re: Length of unpacked string for "hex" data
in thread Length of unpacked string for "hex" data

Thanks, very cool. And I like the dispatch table trick as well; seems I have another app where that will be useful. For the present case I'll stick with your "if"; it's less intrusive than mine.

I noticed you used a lower-case "a" in the template:

"A2C/a"

Meaning to parse on a null-padded string rather than a space-padded one. Is that important here?

Cheers,
-Ken

"This bounty hunter is my kind of scum: Fearless and inventive." --J.T. Hutt


Comment on Re^2: Length of unpacked string for "hex" data
Download Code
Re^3: Length of unpacked string for "hex" data
by ikegami (Pope) on Apr 24, 2006 at 23:01 UTC

    'A' will remove trailing NULs and whitespace.
    'a' will not.

    In other words,
    ($str) = unpack('c/A', $data);
    is equivalent to
    ($str) = unpack('c/a', $data);
    $str =~ s/[\0\s]+$//;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2014-07-26 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls