http://www.perlmonks.org?node_id=1018406


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?

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