in reply to Fetdching filenames starting numbers.
your search() function is quite broken. Let me rewrite a bit of your code and make comments:
my $myfile = ">mytext.txt"; open(FILE, $myfile ) || "can not open: $!\n"; # please do not quote "$vars" # $ perldoc -q 'quoting.*vars' my ($fil,$dir) = (0,0); sub search { return if /^\.+$/ or /^ws_ftp/i; # i don#t know what the broken syntax ala # ($_ != /../) should mean, but it was nonsense # see perlop for '=~' and perlvar for $_ # the return statement is important # exiting from sub via next is bad and you'll get # warnings if( ! -l and -d _ ){ # the _ filehandle is described in `perldoc -f stat` print FILE "\n\nDIRECTORY\t\t$File::Find::name\n", ("-" x 20) , "\n"; $dir++; } else { print FILE "$_\n"; $fil++ } }
consider reading about perlstyle, perloperators, perlsyntax and control statements, perlsubroutines, and of course on the 'strict' pragma and on the -w switch (perlrun) and the 'warnings' pragma.
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Fetdching filenames starting numbers.
by Anonymous Monk on Aug 22, 2002 at 16:57 UTC | |
by fruiture (Curate) on Aug 22, 2002 at 17:04 UTC | |
by twerq (Deacon) on Aug 22, 2002 at 19:34 UTC | |
by Anonymous Monk on Aug 22, 2002 at 18:51 UTC |