John Giordano wrote:
> $grep_deferred = system ('findstr DeferredStatus response1');
>
> print "$grep_deferred\n\n";
[snip]
> $grep_deferred has this in it:
>
> <a href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"><img
> src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
> Status"></a>
Are you sure? Try printing out "bloop\nblip\n$grep_deferred\nblep\n" and see
whether this <a href> line comes between "blip" and "blep".
>From `perldoc -f system`:
The return value is the exit status of the program as returned
by the `wait' call. To get the actual exit value divide by 256.
So if $grep_deferred is the return value from system, it's probably a
number. The line you're seeing on the screen is presumably the output of
findstr, which went to STDOUT; since you didn't redirect STDOUT, it went the
same place your print went.
You probably want `` (backticks).
ObTMTOWTDI: if you're looking for a fixed substring such as '<a ', then
consider using index() rather than regular expressions. See useless
benchmark at the end.
Cheers,
Philip
#!perl -w
use strict;
use Benchmark 'cmpthese';
cmpthese(5_000_000, {
'index.start.found' => sub { $a = index '<a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"><img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"></a>', '<a '; },
'index.start.notfound' => sub { $a = index '[a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"><img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"></a>', '<a '; },
'regex.start.found' => sub { $a = '<a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"><img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"></a>' =~ /<a /; },
'regex.start.notfound' => sub { $a = '[a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"><img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"></a>' =~ /<a /; },
'index.end.found' => sub { $a = index 'fhuhge8a goija fgoja w04gua
roigj oöijf g9a8u onigö lfsdkj gölija osij ga0 jügojar öoigj öosijd ü08g9u
gaji fäöigjah+w r0g9j aäüjäfpoiajs öoijfd +ajsd fäüpioaj öwoeijf öoasuidhf
p9iawh üefhaj woeijg awopihg apiuehrg üaiowj eoöfigjaw ejif<a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"><img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"></a>', '<a '; },
'index.end.notfound' => sub { $a = index 'fhuhge8a goija fgoja w04gua
roigj oöijf g9a8u onigö lfsdkj gölija osij ga0 jügojar öoigj öosijd ü08g9u
gaji fäöigjah+w r0g9j aäüjäfpoiajs öoijfd +ajsd fäüpioaj öwoeijf öoasuidhf
p9iawh üefhaj woeijg awopihg apiuehrg üaiowj eoöfigjaw ejif[a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"><img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"></a>', '<a '; },
'regex.end.found' => sub { $a = 'fhuhge8a goija fgoja w04gua roigj
oöijf g9a8u onigö lfsdkj gölija osij ga0 jügojar öoigj öosijd ü08g9u gaji
fäöigjah+w r0g9j aäüjäfpoiajs öoijfd +ajsd fäüpioaj öwoeijf öoasuidhf p9iawh
üefhaj woeijg awopihg apiuehrg üaiowj eoöfigjaw ejif<a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"><img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"></a>' =~ /<a /; },
'regex.end.notfound' => sub { $a = 'fhuhge8a goija fgoja w04gua roigj
oöijf g9a8u onigö lfsdkj gölija osij ga0 jügojar öoigj öosijd ü08g9u gaji
fäöigjah+w r0g9j aäüjäfpoiajs öoijfd +ajsd fäüpioaj öwoeijf öoasuidhf p9iawh
üefhaj woeijg awopihg apiuehrg üaiowj eoöfigjaw ejif[a
href="/c9410ee04de9845704db8951dfde015b/DeferredStatus"><img
src="/images/btnstats.gif" width=120 height=40 border=0 alt="Mail
Status"></a>' =~ /<a /; },
'assign' => sub { $a = 1; },
});
__END__
Output:
Benchmark: timing 5000000 iterations of assign, index.end.found,
index.end.notfound, index.start.found, inde
x.start.notfound, regex.end.found, regex.end.notfound, regex.start.found,
regex.start.notfound...
assign: 0 wallclock secs ( 1.02 usr + 0.00 sys = 1.02 CPU) @
4897159.65/s (n=5000000)
index.end.found: 9 wallclock secs ( 9.79 usr + 0.00 sys = 9.79 CPU) @
510516.64/s (n=5000000)
index.end.notfound: 12 wallclock secs (12.38 usr + 0.00 sys = 12.38 CPU) @
404007.76/s (n=5000000)
index.start.found: 3 wallclock secs ( 2.49 usr + 0.00 sys = 2.49 CPU) @
2004811.55/s (n=5000000)
index.start.notfound: 5 wallclock secs ( 5.42 usr + 0.00 sys = 5.42 CPU)
@ 922849.76/s (n=5000000)
regex.end.found: 12 wallclock secs (11.42 usr + 0.00 sys = 11.42 CPU) @
437943.42/s (n=5000000)
regex.end.notfound: 13 wallclock secs (13.34 usr + 0.00 sys = 13.34 CPU) @
374840.69/s (n=5000000)
regex.start.found: 5 wallclock secs ( 3.91 usr + 0.00 sys = 3.91 CPU) @
1280081.93/s (n=5000000)
regex.start.notfound: 7 wallclock secs ( 6.38 usr + 0.00 sys = 6.38 CPU)
@ 783821.92/s (n=5000000)
Rate regex.end.notfound index.end.notfound
regex.end.found index.end.found regex.start.notfound index.start.notfound
regex.start.found index.start.found assign
regex.end.notfound 374841/s -- -7%
-14% -27% -52% -59% -71%
-81% -92%
index.end.notfound 404008/s 8% --
-8% -21% -48% -56% -68%
-80% -92%
regex.end.found 437943/s 17% 8%
-- -14% -44% -53% -66%
-78% -91%
index.end.found 510517/s 36% 26%
17% -- -35% -45% -60%
-75% -90%
regex.start.notfound 783822/s 109% 94%
79% 54% -- -15% -39%
-61% -84%
index.start.notfound 922850/s 146% 128%
111% 81% 18% -- -28%
-54% -81%
regex.start.found 1280082/s 242% 217%
192% 151% 63% 39% --
-36% -74%
index.start.found 2004812/s 435% 396%
358% 293% 156% 117% 57%
-- -59%
assign 4897160/s 1206% 1112%
1018% 859% 525% 431% 283%
144% --
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users