check wildcards within a sub
--===============0616285756==
Content-Type: multipart/alternative; boundary="0-644577623-1249707283=:8234"
--0-644577623-1249707283=:8234
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
I need to check image*.tiff if exists (just any one match is ok) within the=
following code. pls advise using glob or anything.
use Win32::Job;
my $job =3D Win32::Job->new;
$job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
=C2=A0 $ok =3D $job->watch( sub {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 1 if (-e "image*.tiff") || slee=
p (30);
=C2=A0=C2=A0 }
, 1);
=0A=0A=0A Yahoo!=E9=A6=99=E6=B8=AF=E6=8F=90ä=BE=9B=E7=B6=B2ä=B8=8A =
=E5=AE=89=E5=85=A8=E6=94=BB=E7=95=A5=EF=BC=8C=E6=95=99ä=BD =A0=E5=A6=82ä=
=BD=95=E9=98=B2=E7=AF=84=E9=BB=91=E5=AE=A2! =E8=AB=8B=E5=89=8D=E5=BE=80 htt=
p://hk.promo.yahoo.com/security/ ä=BA=86=E8=A7=A3=E6=9B=B4=E5=A4=9A!
--0-644577623-1249707283=:8234
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<table cellspacing=3D"0" cellpadding=3D"0" border=3D"0" ><tr><td valign=3D"=
top" style=3D"font: inherit;">I need to check image*.tiff if exists (just a=
ny one match is ok) within the following code. pls advise using glob or any=
thing.<br><br>use Win32::Job;<br>my $job =3D Win32::Job->new;<br>$job-&g=
t;spawn($Config{perlpath}, "perl c:\\test\\a.pl");<br> $ok =3D $job-&=
gt;watch( sub {<br> return 1 if (-e "im=
age*.tiff") || sleep (30);<br> }<br>, 1);<br></td></tr></table>=
<br>=0A =0A=0A=0A=0A <hr size=3D1>Yahoo!=E9=A6=99=E6=B8=AF=E6=8F=
=90ä=BE=9B=E7=B6=B2ä=B8=8A=E5=AE=89=E5=85=A8=E6=94=BB=E7 =95=A5=EF=BC=8C=
=E6=95=99ä=BD=A0=E5=A6=82ä=BD=95=E9=98=B2=E7=AF=84=E9=BB =91=E5=AE=A2!<a=
href=3D"http://hk.promo.yahoo.com/security/"><b>ä=BA=86=E8=A7=A3=E6=9B=
=B4=E5=A4=9A</b></a>
--0-644577623-1249707283=:8234--
--===============0616285756==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0616285756==--
Re: check wildcards within a sub
--===============1923068274==
Content-Type: multipart/alternative; boundary="0-675397093-1249745415=:32427"
--0-675397093-1249745415=:32427
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
i want to kill spawned process and its child if image*.tiff exists or timeo=
ut.
c:\\test\\a.pl is to generate the tiff by print the acrobat reader to defau=
lt printer which creates the tif file.
i have tried the following without success.
use Win32::Job;
my $job =3D Win32::Job->new;
# Run for 10 seconds
print "start ......";
#$job->spawn($Config{perlpath}, "perl");
$job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
#$job->run(10);
=C2=A0 $ok =3D $job->watch( sub {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 1 if ((glob "image*.tiff"=
) || sleep (30));
=C2=A0=C2=A0 }
, 1);
If image*.tiff is changed to an file already existed, the spawn process is =
terminated very quickly. It could not detect image*.tiff if it is generated=
by a.pl (by printer driver). it times out after 30 secs.
I am a newbie to perl. pls kindly advise. if you know win32::process, pls a=
dvise code, too.
--- 2009=E5=B9=B48=E6=9C=888=E6=97=A5 =E6=98=9F=E6=9C=9F=E5=85=AD=EF=BC=8CM=
ichael Zeng <galaxy2004 [at] gmail.com> =E5=AF=AB=E9=81=93=EF=B9=95
=E5=AF=84ä=BB=B6ä=BA=BA: Michael Zeng <galaxy2004 [at] gmail.com>
ä=B8=BB=E9=A1=8C: Re: check wildcards within a sub
=E6=94=B6ä=BB=B6ä=BA=BA: "Aclhk Aclhk" <aclhkaclhk [at] ymail.com>
=E6=97=A5=E6=9C=9F: 2009=E5=B9=B48=E6=9C=888=E6=97=A5,=E6=98=9F=E6=9C=9F=E5=
=85=AD,ä=B8=8B=E5=8D=8812:50
if=C2=A0 ( glob "image*.tiff" )=C2=A0=C2=A0 {=0A=C2=A0=C2=A0=C2=A0 .....=0A=
}=0A=C2=A0=0A
=C2=A0=0AOn Sat, Aug 8, 2009 at 12:54 PM, Aclhk Aclhk <aclhkaclhk [at] ymail.com=
> wrote:
=0A=0A=0A=0A=0AI need to check image*.tiff if exists (just any one match is=
ok) within the following code. pls advise using glob or anything.
use Win32::Job;
my $job =3D Win32::Job->new;
$job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
=0A=C2=A0 $ok =3D $job->watch( sub {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 1 if (-e "image*.tiff") || slee=
p (30);
=C2=A0=C2=A0 }
, 1);
=0A=0AYahoo!=E9=A6=99=E6=B8=AF=E6=8F=90ä=BE=9B=E7=B6=B2ä =B8=8A=E5=AE=89=
=E5=85=A8=E6=94=BB=E7=95=A5=EF=BC=8C=E6=95=99ä=BD=A0=E5=A6 =82ä=BD=95=E9=
=98=B2=E7=AF=84=E9=BB=91=E5=AE=A2!ä=BA=86=E8=A7=A3=E6=9B=B 4=E5=A4=9A
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
=0ATo unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
=0A
--
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Yours Sincerely
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Zeng H=
ong
=0A=0A=0A=0A Yahoo!=E9=A6=99=E6=B8=AF=E6=8F=90ä=BE=9B=E7=B6=B2ä=B8=
=8A=E5=AE=89=E5=85=A8=E6=94=BB=E7=95=A5=EF=BC=8C=E6=95=99ä =BD=A0=E5=A6=82=
ä=BD=95=E9=98=B2=E7=AF=84=E9=BB=91=E5=AE=A2! =E8=AB=8B=E5=89=8D=E5=BE=80 =
http://hk.promo.yahoo.com/security/ ä=BA=86=E8=A7=A3=E6=9B=B4=E5=A4=9A!
--0-675397093-1249745415=:32427
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<table cellspacing=3D"0" cellpadding=3D"0" border=3D"0" ><tr><td valign=3D"=
top" style=3D"font: inherit;">i want to kill spawned process and its child =
if image*.tiff exists or timeout.<br>c:\\test\\a.pl is to generate the tiff=
by print the acrobat reader to default printer which creates the tif file.=
<br><br>i have tried the following without success.<br><br>use Win32::Job;<=
br><br>my $job =3D Win32::Job->new;<br><br># Run for 10 seconds<br>print=
"start ......";<br>#$job->spawn($Config{perlpath}, "perl");<br>$job->=
;spawn($Config{perlpath}, "perl c:\\test\\a.pl");<br>#$job->run(10);<br>=
<br><br> $ok =3D $job->watch( sub {<br> &nb=
sp; return 1 if ((glob "image*.tiff") || sleep (30));<br> =
}<br>, 1);<br><br>If image*.tiff is changed to an file already exist=
ed, the spawn process is terminated very quickly. It could not detect image=
*.tiff if it is generated by a.pl (by printer driver). it times out after 3=
0
secs.<br><br>I am a newbie to perl. pls kindly advise. if you know win32::=
process, pls advise code, too.<br><br>--- <b>2009=E5=B9=B48=E6=9C=888=E6=97=
=A5 =E6=98=9F=E6=9C=9F=E5=85=AD=EF=BC=8CMichael Zeng <i><galaxy2004 [at] gmai=
l.com></i></b> =E5=AF=AB=E9=81=93=EF=B9=95<br><blockquote style=3D"borde=
r-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><=
br>=E5=AF=84ä=BB=B6ä=BA=BA: Michael Zeng <galaxy2004 [at] gmail.com><b=
r>ä=B8=BB=E9=A1=8C: Re: check wildcards within a sub<br>=E6=94=B6ä=BB=
=B6ä=BA=BA: "Aclhk Aclhk" <aclhkaclhk [at] ymail.com><br>=E6=97=A5=E6=9C=
=9F: 2009=E5=B9=B48=E6=9C=888=E6=97=A5,=E6=98=9F=E6=9C=9F=E5=85=A D,ä=B8=
=8B=E5=8D=8812:50<br><br><div id=3D"yiv2142491492"><div>if ( glob "im=
age*.tiff" ) {</div>=0A<div> .....</div>=0A<d=
iv>}</div>=0A<div> </div>=0A<div><br><br> </div>=0A<div class=3D"=
gmail_quote">On Sat, Aug 8, 2009 at 12:54 PM, Aclhk Aclhk <span dir=3D"ltr"=
><<a rel=3D"nofollow" ymailto=3D"mailto:aclhkaclhk [at] ymail.com" target=3D"=
_blank" href=3D"/mc/compose?to=3Daclhkaclhk [at] ymail.com">aclhkaclhk [at] ym ail.com=
</a>></span> wrote:<br>=0A<blockquote class=3D"gmail_quote" style=3D"bor=
der-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-=
left: 1ex;">=0A<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0">=0A<=
tbody>=0A<tr>=0A<td valign=3D"top">I need to check image*.tiff if exists (j=
ust any one match is ok) within the following code. pls advise using glob o=
r anything.<br><br>use Win32::Job;<br>my $job =3D Win32::Job->new;<br>$j=
ob->spawn($Config{perlpath}, "perl c:\\test\\a.pl");<br>=0A $ok =
=3D $job->watch( sub {<br> return 1 =
if (-e "image*.tiff") || sleep (30);<br> }<br>, 1);<br></td></t=
r></tbody></table><br>=0A<hr size=3D"1">=0AYahoo!=E9=A6=99=E6=B8=AF=E6=8F=
=90ä=BE=9B=E7=B6=B2ä=B8=8A=E5=AE=89=E5=85=A8=E6=94=BB=E7 =95=A5=EF=BC=8C=
=E6=95=99ä=BD=A0=E5=A6=82ä=BD=95=E9=98=B2=E7=AF=84=E9=BB =91=E5=AE=A2!<a=
rel=3D"nofollow" target=3D"_blank" href=3D"http://hk.promo.yahoo.com/secur=
ity/"><b>ä=BA=86=E8=A7=A3=E6=9B=B4=E5=A4=9A</b></a><br>__________________=
_____________________________<br>ActivePerl mailing list<br><a rel=3D"nofol=
low" ymailto=3D"mailto:ActivePerl [at] listserv.ActiveState.com" target=3D"_blan=
k" href=3D"/mc/compose?to=3DActivePerl [at] listserv.ActiveState.com ">ActivePerl=
[at] listserv.ActiveState.com</a><br>=0ATo unsubscribe: <a rel=3D"nofollow" tar=
get=3D"_blank" href=3D"http://listserv.activestate.com/mailman/mysubs">http =
://listserv.ActiveState.com/mailman/mysubs</a><br></blockquote></div><br><b=
r clear=3D"all">=0A<div></div><br>-- <br> =
Yours Sincerely<br> =
Zeng Hong <br>=0A</div></blockquote></td></tr></table><=
br>=0A =0A=0A=0A=0A <hr size=3D1>Yahoo!=E9=A6=99=E6=B8=AF=E6=8F=
=90ä=BE=9B=E7=B6=B2ä=B8=8A=E5=AE=89=E5=85=A8=E6=94=BB=E7 =95=A5=EF=BC=8C=
=E6=95=99ä=BD=A0=E5=A6=82ä=BD=95=E9=98=B2=E7=AF=84=E9=BB =91=E5=AE=A2!<a=
href=3D"http://hk.promo.yahoo.com/security/"><b>ä=BA=86=E8=A7=A3=E6=9B=
=B4=E5=A4=9A</b></a>
--0-675397093-1249745415=:32427--
--===============1923068274==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1923068274==--
Re: check wildcards within a sub
Aclhk Aclhk wrote:
> i want to kill spawned process and its child if image*.tiff exists or
> timeout.
> c:\\test\\a.pl is to generate the tiff by print the acrobat reader to
> default printer which creates the tif file.
>
> i have tried the following without success.
>
> use Win32::Job;
>
> my $job = Win32::Job->new;
>
> # Run for 10 seconds
> print "start ......";
> #$job->spawn($Config{perlpath}, "perl");
> $job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
> #$job->run(10);
>
>
> $ok = $job->watch( sub {
> return 1 if ((glob "image*.tiff") || sleep (30));
> }
> , 1);
>
> If image*.tiff is changed to an file already existed, the spawn process
> is terminated very quickly. It could not detect image*.tiff if it is
> generated by a.pl (by printer driver). it times out after 30 secs.
>
> I am a newbie to perl. pls kindly advise. if you know win32::process,
> pls advise code, too.
This seems to work (assuming the TIFF is generated in the current working
dir and the TIFF created is named something like 'image1.tiff':
use strict;
use warnings;
use Config;
use Win32::Job;
my $MAX_WAIT = 10; # seconds to wait for TIFF
my $job = Win32::Job->new;
$job->spawn($Config{perlpath}, 'perl a.pl');
my $start = time;
# assumes that a TIFF file is created in this (.) dir
print "watch for TIFF\n" if $debug;
$job->watch(
sub {
return 1 if glob ('image*.tiff');
my $diff = time - $start;
if ($diff > $MAX_WAIT) {
print "Timeout waiting for TIFF - exiting\n";
return 1;
}
return 0;
}, 1);
__END__
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: check wildcards within a sub
Bill Luebkert wrote:
> Aclhk Aclhk wrote:
>> i want to kill spawned process and its child if image*.tiff exists or
>> timeout.
>> c:\\test\\a.pl is to generate the tiff by print the acrobat reader to
>> default printer which creates the tif file.
>>
>> i have tried the following without success.
>>
>> use Win32::Job;
>>
>> my $job = Win32::Job->new;
>>
>> # Run for 10 seconds
>> print "start ......";
>> #$job->spawn($Config{perlpath}, "perl");
>> $job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
>> #$job->run(10);
>>
>>
>> $ok = $job->watch( sub {
>> return 1 if ((glob "image*.tiff") || sleep (30));
>> }
>> , 1);
>>
>> If image*.tiff is changed to an file already existed, the spawn process
>> is terminated very quickly. It could not detect image*.tiff if it is
>> generated by a.pl (by printer driver). it times out after 30 secs.
>>
>> I am a newbie to perl. pls kindly advise. if you know win32::process,
>> pls advise code, too.
>
> This seems to work (assuming the TIFF is generated in the current working
> dir and the TIFF created is named something like 'image1.tiff':
>
> use strict;
> use warnings;
> use Config;
> use Win32::Job;
>
> my $MAX_WAIT = 10; # seconds to wait for TIFF
>
> my $job = Win32::Job->new;
> $job->spawn($Config{perlpath}, 'perl a.pl');
>
> my $start = time;
>
> # assumes that a TIFF file is created in this (.) dir
>
> print "watch for TIFF\n" if $debug;
> $job->watch(
> sub {
> return 1 if glob ('image*.tiff');
> my $diff = time - $start;
> if ($diff > $MAX_WAIT) {
> print "Timeout waiting for TIFF - exiting\n";
I left the kill part out - it would go here:
> return 1;
> }
> return 0;
> }, 1);
>
> __END__
_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs