yitzle wrote: > 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); > }
This made my eyes bleed. Does your input file have one record per line, or records in blocks separated by blank lines, or what? If you're trying to do what I think you're trying to do, it can be done in a couple of lines of code, but please be specific about your objective here. Like "I have this -->, and want this -->". -- [EMAIL PROTECTED] [pgp: 8A8FA6DE] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/