Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Casting return value of unpack properly

by AnomalousMonk (Abbot)
on Feb 12, 2013 at 16:33 UTC ( #1018406=note: print w/ replies, xml ) Need Help??


in reply to Casting return value of unpack properly

... it always performs the join even if there is no second element.

By this, I think you mean that there is a  '_' present in all cases, even if it the last (and dangling) character in the unpack-ed string.

I tried essentially the same code as jethro under ActiveState 5.8.9 and Strawberries 5.10.1.5, 5.12.3.0 and 5.14.2.1 and get no extraneous underscore.

>perl -wMstrict -le "my $p = 'ABCDabcdABCDabcd' . pack 'V', 0x3039; print qq{'$p'}; ;; my $unp = join '_', unpack 'H32V*', $p; print qq{'$unp'}; ;; $p = 'ABCDabcdABCDabcd'; print qq{'$p'}; ;; $unp = join '_', unpack 'H32V*', $p; print qq{'$p'}; " 'ABCDabcdABCDabcd90 ' '41424344616263644142434461626364_12345' 'ABCDabcdABCDabcd' 'ABCDabcdABCDabcd'

Can you supply a short, stand-alone code example that demonstrates the effect you seek to avoid?


Comment on Re: Casting return value of unpack properly
Select or Download Code
Re^2: Casting return value of unpack properly
by puterboy (Scribe) on Feb 12, 2013 at 16:41 UTC
    I can't replicate it now. Perhaps before I was using 'B*' or 'A*' instead of 'V*'... but not sure what happened. I apologize for taking your time on what seems to be a non-issue.

      Oh, well... Just one of those days... sigh

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2014-09-20 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls