<?xml version="1.0" encoding="windows-1252"?>
<node id="1018395" title="Casting return value of unpack properly" created="2013-02-12 10:34:14" updated="2013-02-12 10:34:14">
<type id="115">
perlquestion</type>
<author id="725401">
puterboy</author>
<data>
<field name="doctext">
I am using unpack to unpack an element that consists of a 32 byte hex string plus an optional unsigned integer. If the integer exists, I want to join the 2 with an underscore.&lt;br&gt;&lt;br&gt;

I tried: 
&lt;code&gt;
join("_", unpack("H32V*", $string));
&lt;/code&gt;
but it always performs the join even if there is no second element. Adding an intermediate assignment, made it work:
&lt;code&gt;
my @temp = unpack("H32V*", $string);
join("_", @temp);
&lt;/code&gt;
But that seems kludgy and I would like to avoid it. So, is there any way to properly cast/assign the result of unpack so that an undefined second element is ignored by join without using an intermediate variable? &lt;br&gt;&lt;br&gt;
</field>
</data>
</node>
