... 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?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|