Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Casting return value of unpack properly

by AnomalousMonk (Canon)
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?

Comment on Re: Casting return value of unpack properly
Select or Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-12-01 22:55 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (29 votes), past polls