On Tue, Nov 11, 2008 at 5:03 PM, JC Janos <[EMAIL PROTECTED]> wrote:
> When I run this script,
>
> $result = `$WGET $file`;
> print $result . "\n";
> if ( $result =~ m/saved/ ){
> print "MATCH\n";
> } else {
> print "NO MATCH\n";
> }
>
> It outputs,
>
> 2008-11-11 07:43:34 (526 KB/s) - `test.zip' saved [1517245/1517245]
> NO MATCH
>
> But if I change,
>
> - $result = `$WGET $file`;
> + $result = "2008-11-11 07:43:34 (526 KB/s) - `test.zip' saved
> [1517245/1517245]";
>
> the script now outputs
>
> 2008-11-11 07:43:34 (526 KB/s) - `test.zip' saved [1517245/1517245]
> MATCH
>
> Why doesn't the match,
>
> $result =~ m/saved/
>
> work in the first case?
>
> --JC
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>
I am not 100% certain but I would say because in the first instance $WGET
$file does not result in anything, the printed line is not printed by your
program but by the wget command.
Try modifying your script to the follwoing:
$result = `$WGET $file`;
print "Result = $result\n";
if ( $result =~ m/saved/ ){
print "MATCH\n";
} else {
print "NO MATCH\n";
}
That way you will be certain that what is written to the screen is written
by your program.
Regards,
Rob