Today around 1:41pm, Tom Christiansen hammered out this masterpiece:

: >  my %hash = &func();
: >  print "$_\n" foreach keys %hash;
: 
: >To work just like this:
: 
: >  print "$_\n" foreach keys &func();
: 
: >In my, 'pretending to just learn' mode, I don't understand.  Perl will assign
: >the LIST to the hash in example one, but in example two, it croaks.
: 
: A LIST is not a HASH.  Learn that.  Be done with it.  Move on.

Goodness man, I got it, I have gotten it.  Perhaps I'm using wrong terminology,
but I understand.

: >Removing intermediate data structures is easy in Perl, but not this case,
: >instead, I have to do this:
: 
: >%{{&func()}};
: 
: >How... not easy to learn.
: 
: >Especially since it's not documented.  Perhaps, at least for the current<SNIP>
: 
: Say what?

Well, there is a mention to the effect of:

  @uniq = keys %{{%foo,%baz}};

in perlfaq4.

And perlfunc says that keys only works on 'named hashes'.  I suppose to a
seasoned veteran, that's sufficient.

There is no documentation that states:

``keys() just doesn't work on lists and/or arrays, you must use this syntax to
force that to work:

  @array = keys %{{@array}};
''

Or something like that.

This suggestion was brought up as a means to make these functions more user
friendly.

If it's impossible, then I'll be glad to forget about it.

[Insert many replies that agree here, I'm sure.]

-- 
print(join(' ', qw(Casey R. Tweten)));my $sig={mail=>'[EMAIL PROTECTED]',site=>
'http://home.kiski.net/~crt'};print "\n",'.'x(length($sig->{site})+6),"\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys%{$sig};
my $VERSION = '0.01'; #'patched' by Jerrad Pierce <belg4mit at MIT dot EDU>

Reply via email to