in reply to pushing a $variable into an array with varible name

It looks like you might want a hash of arrays.
@vol = ( "vol1", "vol2" ); $contextID = 9; $datastream = "this is just a data stream test"; ( $a, $b, $c, $d, $e, $f, $g ) = split /\s+/, $datastream; my %hash; $"=" "; #see 'perldoc perlvar' for what this means push @{$hash{"$contextID-$vol[0]"}}, $a; push @{$hash{"$contextID-$vol[0]"}}, $b; print "output0: @{$hash{"$contextID-$vol[0]"}}\n"; push @{$hash{"$contextID-$vol[1]"}}, $a; print "output1: @{{"$contextID-$vol[1]"}}\n";

thor

Update: Added double-quotes to hash indicies as per request below

Replies are listed 'Best First'.
Re^2: pushing a $variable into an array with varible name
by Roy Johnson (Monsignor) on Jun 18, 2004 at 00:57 UTC
    You need double-quotes around those hash subscripts.

    We're not really tightening our belts, it just feels that way because we're getting fatter.