Skip to content

Instantly share code, notes, and snippets.

@sergot
Created February 23, 2012 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergot/1892277 to your computer and use it in GitHub Desktop.
Save sergot/1892277 to your computer and use it in GitHub Desktop.
rmdir function for Perl 6
use v6;
sub rmdir($path) {
die "$path does not exist." unless $path.IO.e;
die "$path is not a directory." unless $path.IO.d;
die "$path directory is not empty." if dir $path;
try {
pir::new__PS('OS').rm($path);
}
$! ?? fail($!) !! Bool::True;
}
rmdir('/path/to/dir');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment