From: gohaku <mailto:[EMAIL PROTECTED]> wrote:
: I would like to know if there is a cleaner way of Merging : Hash Keys with Arrays and what the correct terminology is : for describing this merging. : I find the syntax somewhat confusing since @ usually refers : to an Array while : % refers to a Hash : : @array = qw(1 2 3 4 5); : : #Hash Key and Array Merging... : @[EMAIL PROTECTED]; : #OR.... @[EMAIL PROTECTED] = ""; : #.......fin : : print join(" ",sort keys %VALS),"\n"; : #1 2 3 4 5 Try reading about Slices in 'perldata'. Basically, when referring to a single value in a hash you use the scalar prefix '$'. my %hash = ( foo => 'baz', bar => undef ); print $hash{foo}; delete $hash{bar}; When referring to a list of keys use the array prefix '@'. $hash{bar} = 'one'; print "$_\n" foreach @hash{ qw| foo bar | }; @hash{ qw| foo bar | } = @hash{ qw| bar foo | }; When referring to the entire hash use the hash prefix '%'. print "$_\n" foreach @hash{ sort keys %hash }; print "$_\n" foreach sort values %hash; HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>