sub AUTOLOAD { our $AUTOLOAD; my $s = shift; $AUTOLOAD =~ /.*::(get|scan)(_\w+)_files*$/ or croak "No such method: $AUTOLOAD"; my ($mode, $type) = ($1, $2); # Get the files and return appropriate file(s) based on method called return @{$s->{$type.'_files'}} if ($mode eq 'get'); return new ref($s).'::Iterator' (@{$s->{$type.'_files'}}) if ($mode eq 'scan'); }