Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: File::Find question

by coolmichael (Deacon)
on Feb 23, 2003 at 07:30 UTC ( #237866=note: print w/ replies, xml ) Need Help??


in reply to Re: File::Find question
in thread File::Find question

One of my first memories with Perl is reading about find2perl. I had no idea that you could translate shell to perl so easily. Anyway, using find2perl is very easy and demonstrates how to use File::Find.

[michael]$ find2perl /path/to/directory -name '*.b' -exec rm {} \;
(mostly copied and pasted into the shell) which prints a complete File::Find based Perl script ready to run. It's a little verbose, so I've removed some of the less important lines for the sake of clarity.
#! /usr/bin/perl -w use strict; use File::Find (); sub wanted { /^.*\.b\z/s && (unlink($_) || warn "$name: $!\n"); } # Traverse desired filesystems File::Find::find({wanted => \&wanted}, '/path/to/directory'); exit;
--
negativespace.net - all things inbetween.


Comment on Re: Re: File::Find question
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-08-23 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (174 votes), past polls