Today around 3:01pm, John Porter hammered out this masterpiece:

: Nathan Torkington wrote:
: > John Porter writes:
: > > I suppose that's true.  But why would 
: > >   %( foo => 1, bar => 2 )
: > > be "working harder" than
: > >   %{{ foo => 1, bar => 2 }}
: > > ??? It's few keystrokes and would be a less tricky concept
: > > to remember.
: > 
: > It's a new syntax, not orthogonal to anything we already have.  
: 
: So?  Perl's not like that.  Perl is diagonal.  And this is just
: another corner being cut.

As a user, I should be able to expect this:

  sub func {
    return ( qw/KeyOne Value1 KeyTwo Value2/ );
  }

  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.

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 version
of Perl, this should be documented in perlfunc under keys(), values() and
each().  Also in perlfaq4, although I bet this is not a frequent question.

-- 

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