Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

bsdz's scratchpad

by bsdz (Friar)
on Oct 11, 2004 at 22:22 UTC ( #398318=scratchpad: print w/replies, xml ) Need Help??

use Win32::Job; use Data::Dumper; use IO::File; my $fh = new IO::File; tie(*$fh => 'RedirectHandle', \&debug); $job = Win32::Job->new; my $pid = $job->spawn("cmd.exe", q{cmd /c dir}, { stdin => 'NUL', stdout => \*$fh, stderr => \*$fh, }); print $fh $pid; $ok = $job->run(30); print $fh Dumper($job->status); print $fh "Applications finished ok!" if $ok; exit; sub debug { foreach (@_) { map { print "# $_\n" } split /\n/; } } { package RedirectHandle; sub print_handle { my $this = shift; my $handle = $this->{HANDLE}; if (ref($handle) eq 'SCALAR') { $$handle .= $_[0] } elsif (ref($handle) eq 'CODE') { &$handle($_[0]) } else { print $handle $_[0] } 1; } sub TIEHANDLE { my $class = shift; bless({ HANDLE => $_[0] }, $class); } sub PRINT { my $this = shift; $this->print_handle(join("", @_)); } }
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2019-12-15 05:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?