Skip to content

Instantly share code, notes, and snippets.

@gmcharlt
Last active July 11, 2019 21: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 gmcharlt/1bf5f3a77065f0135355d8f927a3f974 to your computer and use it in GitHub Desktop.
Save gmcharlt/1bf5f3a77065f0135355d8f927a3f974 to your computer and use it in GitHub Desktop.
Perl, sometimes continuing to break my brain since 1994
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(say);
use File::Path qw'remove_tree';
system 'mkdir -p foo/bar/baz';
system 'cd foo && ln -s bar quux';
say "foo/quux is a directory! Trust -d!" if -d 'foo/quux';
say "foo/quux is also a symlink! Trust -l!" if -l 'foo/quux';
my @res = stat 'foo/quux';
say "foo/quux is still a directory! Trust stat!" if -d _;
say "foo/quux is not a directory! Trust stat!" if ! -d _;
@res = lstat 'foo/quux';
say "foo/quux is still a directory! Trust lstat!" if -d _;
say "foo/quux is not a directory! Trust lstat!" if ! -d _;
say "File::Path::remove_tree is perfectly safe and understandable! Trust me!";
remove_tree('foo', {verbose => 1});
say "Who do you trust now?";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment