Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Casting return value of unpack properly

by AnomalousMonk (Chancellor)
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, and 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?

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018406]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2018-05-28 10:08 GMT
Find Nodes?
    Voting Booth?