On 11/16/06, Rob Dixon <[EMAIL PROTECTED]> wrote:
Dharshana Eswaran wrote:
[snip]
> my @fields = unpack '(A7)*', $binary;
>
> When i tried compiling, it says that
>
> "Invalid type in unpack: '(' at line 10."
>
> It does not accept this, i tried other combinations too. But it does not
> compile the program.
>
> What should i do?
(Please bottom-post your replies, as it makes long threads like this much easier
to understand. Thanks.)
Oh dear. It looks like you have an ealier version of Perl where unpack has no
sub-templates, altthough I thought it had always been like that. Find out what
version you are running (with perl -v) and consider upgrading. I am using v5.8.8
and bmost people use v5.8 or above.
In the meantime, replace
my @fields = unpack '(A7)*', $binary;
with
my @fields = $binary =~ /.{1,7}/g;
Groups (or sub-templates, if you prefer) were introduced in 5.8. If
you don't have them, it's time to upgrade your Perl. In general, you
should keep reasonably up-to-date. Not only are there bug and security
fixes between releases, but if you don't keep up with the the major
versions, you'll find the advice you get on this list and elsewhere
increasingly unhelpful as your Perl slips more and more out-of-date.
It also means fewer and fewer modules will compile correctly as
authors start to rely on newer behaviors.
If you don't have pack groups, that means your system hasn't been
updated in at least 4 years (5.8.0 was released in 2002). You wouldn't
let your OS go for that long without security fixes. 5.6 to 5.8 was a
pretty big jump, too!
In the meantime, see the perldoc for perlpacktut for some pointers on
using the x-multiplication to do some ad-hoc templating.
HTH,
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org
values of β will give rise to dom!