dash2 has asked for the wisdom of the Perl Monks concerning the following question:
package Array; use Tie::Array; use strict; use vars qw/@ISA $AUTOLOAD/; @ISA = qw/Tie::StdArray/; sub TIEARRAY { my $class = shift; return bless [], $class; } sub AUTOLOAD { my $self = shift; my $method = $AUTOLOAD; $method =~ s/.*:://; foreach (@$self) { no strict 'subs'; $_->$method(@_); } }
So now I can do
my @array; tie (@array, 'Array'); @array = (new Foo,new Bar,new Baz); my $obj = tied @array; $obj->method; # calls method on all objects in the array
But obviously that isn't 31337 enough. So can some obfuscation genius figure out a way to do this:
my @array; tie (@array, 'Array'); @array = (new Foo,new Bar,new Baz); @array->method; # calls method on all objects in the array
?
dave hj~
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 31337 array dereferencing
by Masem (Monsignor) on Jan 31, 2002 at 15:50 UTC |