Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^3: If I had a Free Two Months...

by kelan (Deacon)
on Jun 22, 2005 at 17:12 UTC ( #469098=note: print w/replies, xml ) Need Help??

in reply to Re^2: If I had a Free Two Months...
in thread If I had a Free Two Months...

I knew someone would ask:) I've never used File::Find, which is why I didn't. I don't have much need for recursively processing directories. My post was mostly about showing that it wouldn't take two months to write something similar, rather than present a full solution.

I used system that way on purpose, so that it would go through shell processing. The OP specifically mentioned wanting to send shell commands through, and those probably would be more useful if the shell got to process them.

Replies are listed 'Best First'.
Re^4: If I had a Free Two Months...
by diotalevi (Canon) on Jun 22, 2005 at 17:17 UTC

    Oh oh. Here's the same non-buggy version that does invoke the shell. To fix the bug in your code, you'll need to follow symlinks and whenever considering entering a directory, decide whether you've been there before. Symlinks will cause your existing code to enter infinite loops and to run the command on some things more than once.

    #!perl -w use strict; use File::Find; my ( $start_dir, $command ) = @ARGV; find( sub { system $command if -d }, $start_dir );
      See? Thanks to PM, I know have my whole 2 months back. Awesome, diotalevi, and also kudos to those who've pointed out how to use *NIX find! :D

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://469098]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2022-08-13 10:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found