my @array = ();
push (@array, $rel_path);
## in my code more than one thing is pushed to @array.
push (@{$self->{files}}, \@array);
####
sub next {
my( $self )= @_;
while( 1 ) {
if( @{ $self->{files} } ) {
my $file = shift @{ $self->{files} }; ## HERE!
if( -d $file ) {
push @{ $self->{dirs} }, $file;
}
return $file;
}
if( ! @{ $self->{dirs} } ) {
return;
}
my $dir= shift @{ $self->{dirs} };
if( opendir( DIR, $dir ) ) {
$self->{files}= [
map {
File::Spec->catfile( $dir, $_ );
} File::Spec->no_upwards( readdir(DIR) )
];
closedir DIR;
} else {
warn "opendir failed, $dir: $!\n";
}
}
}
####
my $file;
while( $file = $f->next() ) {
print "@{$_}\n";
}
####
push (@{$self->{output}}, [$rel_path, $var1, $var2]);