in reply to Anonymous Thingies
Simply put, there's nothing you can do with an anonymous thing that you couldn't just as well do with a named thing. For example, to create a reference to a hash of arrays I could:
my @array_one = (1, 2, 3); my @array_two = (3, 4, 5); my %hash = (one => \@array_one, two => \@array_two); my $ref = \%hash;
But it's so much nicer to be able to just say:
my $ref = {one => [ 1, 2, 3 ], two => [ 3, 4, 5 ]};
-sam
PS: Actually, it occurs to me that this isn't quite true with subs, since you can't do 'my sub foo' and get a lexically scoped sub named foo. As such anonymous subs are your only way to make new sub routines at runtime without resorting to eval.
|
|---|