2013.12 is 4.5 years old. I would not recommend learning Perl 6 with that version. Please try to get a more recent version: the documentation for it will be more up to date, and it will be one, if not 2 orders of magnitude faster.
Also, why not use chdir
instead of &*chdir
? The latter being something that is relic from ancient times, afaik. If you just chdir
, you get:
$ perl6 -e 'chdir("/home/account")'
Failed to change the working directory to '/home/account': does not exist
Which is definitely already much more understandable.
Secondly, if a chdir
fails, it returns a Failure
. When a Failure
is sunk (aka being called in "void" context in Perl 5 terms), it will throw the Exception
it contains. Which is what you just saw.
chdir
returns an IO::Path
object if successful, which is True in a Boolean context such as an if
or a ternary:
$ perl6 -e 'say chdir("/home/account") ?? "Yeah!" !! "Alas"'
Alas
But in most cases where you want to do something inside a directory, you will want to use indir( $path, { code to execute } ). That will ensure that no code will be executed in that directory except for the code given as the second parameter.