Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Recursive search and delete

by zentara (Archbishop)
on Nov 16, 2012 at 10:54 UTC ( #1004169=note: print w/ replies, xml ) Need Help??

in reply to Recursive search and delete

And a File::Find example: ( the regex probably needs improvement :-) )

#!/usr/bin/perl # delete all of the *.xml* files recursively use File::Find qw(find); @ARGV = qw(.) unless @ARGV; find sub { return unless -f; return unless $_ =~ /(.*).xml(.*)/; unlink $_ and warn "deleted $_\n"; }, @ARGV; # it would be good to show all dirs to be deleted # and promp user for 'yes' __END__

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Comment on Re: Recursive search and delete
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2015-10-09 18:58 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (250 votes), past polls