|
Posted by John W. Krahn on April 11, 2008, 12:31 am
Please log in for more thread options
A. Sinan Unur wrote:
> $pb5.25660@edtnps89:
>
>> A. Sinan Unur wrote:
> ...
>
>>> @obs{ @fields } = unpack $unpack_tmpl;
>> Don't forget the variable that you want to unpack:
>>
>> @obs{ @fields } = unpack $unpack_tmpl, $_;
>
> I didn't ;-) From perldoc -f unpack:
>
> unpack TEMPLATE,EXPR
> unpack TEMPLATE
> ...
> If EXPR is omitted, unpacks the $_ string.
That must be new for 5.10 cause it doesn't work in 5.8.8
$ perl -le'
$_ = q[1234567890123456789012345678901234567890];
print for unpack q[a4 a7 a3];
'
Not enough arguments for unpack at -e line 3, near "q[a4 a7 a3];"
Execution of -e aborted due to compilation errors.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
|