Skipping fields when using unpack()

J

John Ramsden

I need to extract a couple of ASCII fields from a string of fixed-length
fields, let's say 'ABCxPQxxUVW' in which I'm not interested in characters
in positions indicated by 'x'. This can easily be done by the code line:

($a, $junk1, $p, $junk2, $u) = unpack "A3 A A2 A2 A3", $string;

But I was wondering if there is an unpack() spec one could use in the
control string to skip the junk fields and not have to extract them,
thus making the code slightly shorter.

I have tried reading the unpack and pack perldoc schpiel, but can't see
any obvious solution.


Cheers

John R Ramsden ([email protected])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top