Click here to get back home

Re: Unpack - getting values directly into the correct variables

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Re: Unpack - getting values directly into the correct variables xhoster 04-10-2008
Posted by xhoster on April 10, 2008, 12:02 pm
Please log in for more thread options
PugetSoundSylvia@gmail.com wrote:
>
> while (<LOGFILE>) {
>
> @fields = unpack( $BaseBSPFileTemplate, $_ );
>
> $RecordType = $fields[0];
> $SequenceNumber = $fields[1];
> $RecordTypeSuffix = $fields[2];
>
> ... and so forth ...
>
> Is there a better way to do this - one where the unpack function
> itself would automatically split it into the actual variables
> ($RecordType, $SequenceNumber, $RecordTypeSuffix, etc) - instead of me
> having to have the section that has a bunch of rows like this:

You can assign directly to a list of variables:

my ( $RecordType,
$SequenceNumber,
$RecordTypeSuffix,
# ....
) = unpack( $BaseBSPFileTemplate, $_ );


Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Similar ThreadsPosted
Re: Unpack - getting values directly into the correct variables April 10, 2008, 7:27 pm
Re: Unpack - getting values directly into the correct variables April 10, 2008, 7:50 pm
pack, unpack and 64-bit values February 9, 2006, 12:55 pm
Uploaded File Empty but in correct folder with correct name February 27, 2006, 9:59 pm
assigning multiple hash values to multiple variables May 2, 2006, 7:55 pm
Writing directly to system memory July 14, 2005, 9:51 pm
protect calling files directly? September 29, 2005, 6:47 pm
Exists a Module to transform RTF to PDF, directly January 23, 2008, 3:27 pm
using sort directly on subroutine returning list November 25, 2004, 6:12 pm
How to get array item directly from split result? November 9, 2005, 9:53 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap