Last active
July 11, 2019 21:56
-
-
Save gmcharlt/1bf5f3a77065f0135355d8f927a3f974 to your computer and use it in GitHub Desktop.
Perl, sometimes continuing to break my brain since 1994
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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