Skip to content

Instantly share code, notes, and snippets.

@mlbright
Created March 23, 2013 02:26
Show Gist options
  • Save mlbright/5226140 to your computer and use it in GitHub Desktop.
Save mlbright/5226140 to your computer and use it in GitHub Desktop.
Chattier version of rm -rf. Deletes every path provided on STDIN.
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use File::Path qw (remove_tree);
while ( my $path = <> ) {
chomp $path;
my $errors;
my $ret = remove_tree( $path, { verbose => 1, error => \$errors } );
if (@$errors) {
for my $diag (@$errors) {
my ( $file, $message ) = %$diag;
if ( $file eq '' ) {
say "general error: $message";
}
else {
say "problem unlinking $file: $message";
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment