[Pdx-pm] Reading process output fails prematurely?
Eric Wilhelm
enobacon at gmail.com
Thu Mar 5 09:35:50 PST 2009
# from Michael G Schwern
# on Thursday 05 March 2009 02:50:
>Finally, use a lexical
>filehandle just because there's no reason to muck with global
> filehandles any more.
>
> my $udevmonitor = "/usr/local/sbin/udevmonitor";
> open(my $events, "$udevmonitor |") or die "Can't open $udevmonitor:
> $!";
And for good form, use the 3-arg open so you don't get bit by spaces in
the filename.
open(my $events, '-|', $udevmonitor) or die ...
Yes, udevmonitor will probably not be found on windows or mac and no
linux distro worth its salt would ever create a directory called
something like "/Core Components/", but good habits are hard to break.
You also get to pass arguments to the command without the shell trying
to interpret them.
Someone might want to point out that the 3-arg open is not supported by
perls from a decade ago. If you find yourself transported to said
century, please use the opportunity to point out the impending attacks,
wars, and economic meltdown.
--Eric
--
"Insert random misquote here"
---------------------------------------------------
http://scratchcomputing.com
---------------------------------------------------
More information about the Pdx-pm-list
mailing list