+sub gisle {
+ # background info: @_ = 1; !shift # gives '' not 0
+ # Message-Id: <3C820CE6-4400-4E91-AF43-A3D19B356E68@activestate.com>
+ # http://www.nntp.perl.org/group/perl.perl5.porters/2008/05/msg136625.html
+ mkpath(shift, !shift, 0755);
+}
+
+sub count {
+ opendir D, shift or return -1;
+ my $count = () = readdir D;
+ closedir D or return -1;
+ return $count;
+}
+
+{
+ mkdir 'solo', 0755;
+ chdir 'solo';
+ my $before = count(curdir());
+ cmp_ok($before, '>', 0, "baseline $before");
+
+ gisle('1st', 1);
+ is(count(curdir()), $before + 1, "first after $before");
+
+ $before = count(curdir());
+ gisle('2nd', 1);
+ is(count(curdir()), $before + 1, "second after $before");
+
+ chdir updir();
+ rmtree 'solo';
+}
+
+{
+ mkdir 'solo', 0755;
+ chdir 'solo';
+ my $before = count(curdir());
+ cmp_ok($before, '>', 0, "ARGV $before");
+ {
+ local @ARGV = (1);
+ mkpath('3rd', !shift, 0755);
+ }
+ is(count(curdir()), $before + 1, "third after $before");
+
+ $before = count(curdir());
+ {
+ local @ARGV = (1);
+ mkpath('4th', !shift, 0755);
+ }
+ is(count(curdir()), $before + 1, "fourth after $before");
+
+ chdir updir();
+ rmtree 'solo';
+}
+