print "$1\n" and exit if /.../
Funny to read, but not funny when printing fails for some reason:print and exit exists ONLY if print was successful.
>cat print-and-exit.pl #!/usr/bin/perl use strict; use warnings; close STDOUT if @ARGV; 1 and print "foo" and exit 0; die "Ooops, still here"; >perl print-and-exit.pl foo >perl print-and-exit.pl kaboom print() on closed filehandle STDOUT at print-and-exit.pl line 8. Ooops, still here at print-and-exit.pl line 9. >
Alexander
In reply to Re^2: improve script
by afoken
in thread improve script
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |