exit, warn, die


Before starting to deal with files let's look at a couple of function that can help us. exit() allows us to exit the program at any point withou the need to run to the last line of the code. warn() will print a message on standard error (STDERR) and go on running. die() will print the message on the standard error and stop the execution of the program.

examples/files/exit.p6
#!/usr/bin/perl6
use v6;

say "hello";

exit;

say "world";
examples/files/warn.p6
#!/usr/bin/perl6
use v6;

warn "This is a warning";

say "Hello World";


examples/files/die.p6
#!/usr/bin/perl6
use v6;

say "Before calling die";

die "This will kill the script";

say "This will not show up";


Copyright 2006, 2007, 2008, 2009, 2010 Gabor Szabo http://szabgab.com/ Index | TOC
If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed