Next | Welcome to my ~/bin | 120 |
run("pnmarith $diff @pnm > $tmp"); run("xv $tmp"); run("rm -f $tmp @pnm") unless $LEAVE_TMP_FILES;
xv is John Bradley's image-viewing program; it can display P?M files
run runs a command, gathers its output, checks for errors, etc:
sub run { my $cmd = shift; print $cmd, "\n"; my $context = wantarray; my $result; if (defined $context) { $result = qx{$cmd}; } else { system($cmd); } if ($? != 0) { warn "-- command exist status was $?\n" } $result; }
Note the use of wantarray to check whether output is requested
I imagine my plan was to add a list-context return if I needed it
But I didn't need it, so I left it out
It's nice to see that I sometimes have good judgement
Next | Menu | Copyright © 2005 M. J. Dominus |