Say you have a batch job that does lots and lots and lots of stuff overnight, or even several times an hour. You want to know what's going on with it when you're working on it, so you add
print
or say
statements all over.say &do( $this ) ; say &do( $that ) ; say &do( $the_other_thing ) ;
And it emails you all the time, giving you status updates you don't need. So, you change it.
$debug and say &do( $this ) ; $debug and say &do( $that ) ; $debug and say &do( $the_other_thing ) ;
And you have to remember to set the
$debug
flag for testing.Along comes
IO::Interactive
use IO::Interactive { interactive } ; say { interactive } &do( $this ) ; say { interactive } &do( $that ) ; say { interactive } &do( $the_other_thing ) ;
Now, it can tell if you're running interactively or not, and suppress your prints (by giving a non-writing file handle) when you don't want to print. Absolutely awesome.
You mistyped Interactive in your use :)
ReplyDeleteWell, obviously it isn't working code....
ReplyDeleteBut thanks!