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'); } #### sub new { my $class = shift; bless [@_], $class; } sub next_file { my $self = shift; shift @$self; return $self->[0]; } sub selected_file { (shift)->[0] }