Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: An alternative to File::Find

by etcshadow (Priest)
on Jan 30, 2004 at 06:32 UTC ( #325151=note: print w/replies, xml ) Need Help??


in reply to An alternative to File::Find

Man... if you're gonna suggest something like this, at least make your find command:
"find . -type d -print0 |"
and then in your perl, set
local $/ = "\0";
This is exactly the sort of thing that gives perl a bad rep... it's basically no harder to use print0 and $/="\0", yet you don't do it. It's like people not checking the return value of malloc, for cryin out loud!
------------ :Wq Not an editor command: Wq

Replies are listed 'Best First'.
Re: Re: An alternative to File::Find
by graff (Chancellor) on Jan 30, 2004 at 06:41 UTC
    Right -- that's nice. It would get rid of the "chomp $dir;", and ... um ... AH! It took me a while to get your point: Sometimes, one or more characters within a file name happens to be "\n"! (When this happens it's truly evil, but I know it does happen.) Thanks!

    update: For some reason, the "/usr/bin/find" that comes with solaris 8 does not support the "-print0" flag -- need the GNU version to do that. Oh well.

      Exactly... but you still shouldn't get rid of the chomp... the chomp will just take off the "\0" (chomp removes a trailing $/, even if $/ is set to something other than "\n").
      ------------ :Wq Not an editor command: Wq

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://325151]
help
Chatterbox?
[marto]: good morning all
[prospect]: Good morning ! More Perl learning today, Man that subroutines chapter is tough.
[marto]: tutorials-> Subroutines may be of interest

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2017-07-24 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (348 votes). Check out past polls.