Since we see no other references to this array ref, I'm assuming this code is cut down from its full version.sub next { my $self = shift; while( 1 ) { if ( @{ $self->{output} } ) { my $line = shift @{ $self->{output} }; return $line; }
Add a proper declaration for $olddir above, and:if ( ! @{ $self->{dirs} } ) { return; } my $dir = shift @{ $self->{dirs} }; if (-d $dir) {
I haven't tested this, but the idea is that, since the paths are all absolute, a change in level means a difference in the number of path seperators. (You might want to use a more portable form of the seperator than a literal "/".)if ($oldir){ $self->{level} += ($dir=~tr!/!/!) - ($olddir=~tr!/!/!); } $olddir=$dir;
In reply to Re: Depth Listing in Directory Traversal
by hbo
in thread Depth Listing in Directory Traversal
by crabbdean
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |