in reply to hash name not sticking?

You need to take a look at perlref, if you want to use a hash reference (my $hash = {};). Since you say you don't want to do that, you need to get rid of the dereferencing arrows in your push line.

Try this instead:

    push @{$hash{$1}{$2}}, $try->param($string);

The arrows are only necessary to tell Perl that you want at data stored in the hash pointed to by the scalar $hash. Since you want at a scalar stored in %hash, you don't need the arrow. (Yes, using a HoHoL makes you use more punctuation, but I think you get the drift.)

Remember, the punctuation on the front of the variable name tells you want kind of value you want to use in that case -- it's not part of the variable's name. The arrow helps distinguish between a scalar portion of a hash and a scalar hash (de)reference. (Does this make it clear? I'm not sure I would understand it if I had to read what I'd just written. :| )

Replies are listed 'Best First'.
RE: Re: hash name not sticking?
by jptxs (Curate) on Sep 05, 2000 at 05:05 UTC
    for the curious, i'm an idiot :)

    in the past i have always created anon hashes setting arrays = arrays. well, this time it should have been scaler = scaler, but i just didn't see it. everything else fell out of doing that all wrong. code i ended up using:

    my %hash; foreach my $string ( $try->param ) { if ( $string =~ m/(\d+)_(\d+)/ ) { $hash{$1}{$2} = $try->param($string); } }
    and  <P> then you have:<BR><P>$hash{12}{1} which prints "then you have STRING".