I got an input source that got records of fixed number of lines, eg
Name, Address, Age, Phone, Cell
I'm not interested in Age or Cell.
I'm doing something along the lines of the following. Can I do better?

my @lines = qw/name address age phone cell end/;
my %process = {name=>1, address=>1, phone=>1, end=>1};
my $i = 0;
my $name;
my %hash;
while(<INPUT>) {
        $name = $_ if($lines[$i] eq 'name');
        next unless($process{$lines[$i]});
        $hash{$name}{$lines[$i]} = $_;
} continue {
        $i = ($i++) % (#$lines + 1);
}

One part that really irks me is the hash for listing what lines get processed.
I suppose I can process everything and have a qw// list of what parts
of the hash I want to use at a later point of the code...

Thanks

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to