#!/usr/bin/perl # # $URL: svn://domestic/54/doc/inf/perl-problems/examples/perl/find.pl $ # $Id: find.pl 516 2010-11-28 18:31:09Z $ # use warnings; sub find($); sub find($) { my $name=shift; if(-d $name) { my $dir; unless(opendir $dir, $name) { warn "$0: Impossible to open «$name»: $!\n"; return; } print "$name\n"; $name='' if $name eq '/'; for(readdir $dir) { next if $_ eq '.' or $_ eq '..'; find("$name/$_"); } closedir $dir; } elsif(-f $name) { print "$name\n"; } else { warn "$0: «$name»: $!\n"; } } find($_) for @ARGV; find('.') unless @ARGV;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)