in reply to Re: Re: parsing text file into a hash?
in thread parsing text file into a hash?

Hey, I couldn't get it to compile until I changed the following
{
my ($label, $name1, $name2, $name3, $name4) = split /:/;
$names{$label}{"first"} = $name1;
$names{$label}{"second"} = $name2;
$names{$label}{"third"} = $name3;
$names{$label}{"fourth"} = $name4;
}
...note the changes on $name1 and $name3....{$namex} to $namex;. I'm new at this, so should I have just left it alone? Is there something I just don't know? john
  • Comment on Re: Re: Re: parsing text file into a hash?

Replies are listed 'Best First'.
Re: Re: Re: Re: parsing text file into a hash?
by runrig (Abbot) on Jun 15, 2001 at 23:46 UTC
    Sorry, I guess I didn't read too closely the first time. at least you got the idea. But if that's what you want, you could do this:
    my %names; { my ($label, @names) = split /:/; @{$names{$label}}{qw(first second third fourth)} = @names; }