in reply to dereferencing hash & array refs

Parts of this confuse me ... for any hashes you only care about the values? Why use a hash in the first place then? There may be a reason in the larger context of your program I'm missing. Why do the individual dereferencing functions use map when they're only ever passed scalars?

I guess my bottom line question is what is it that just prevents you from doing this:

my @a = @$a_ref; # I know it's an array my %h = %$h_ref; # I know it's a hash my @h = values(%$h_ref); # I just want the values # Bascically what you're doing above. my @a = (ref($x) eq 'ARRAY') ? @$x : values(%$x);

Replies are listed 'Best First'.
Re: Re: dereferencing hash & array refs
by parv (Parson) on Feb 09, 2003 at 15:07 UTC
    The program is going to be a wrapper around another to be executed via system(). Arguments passed to system() are set via command line options/arguments (w/ help from Getopt::Long), which are stored in a hash. Ergo, as far as system() is concerned, all it needs to see are the values (of the hash).