Hi

If "Request timed out" occurs in the output from PING command you can be quite sure that the request timed out. :-)
Therefore it's be bit to much hazzle to check for embedded newlines (using the \m modifier), one could just say:


 if ($machine_status =~ /Request timed out\./) {

Remember to escape the period (.), it has a speciel meaning in regex (can be any charachter more or less)

Maybe you should also consider using Net::Ping instead of using a system call to the PING command! At least I hope you are checking the return code from the system call. ;-)

Gretar Mar

Trina Espinoza wrote:
Var $machine_status contains this block of data:

machine_status = "Pinging 129.111.3.79 with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.111.3.79:
   Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Approximate round trip times in milli-seconds:
   Minimum = 0ms, Maximum =  0ms, Average =  0ms"

I am trying to do a regular expression to see if the block contains the string "Request timed out." from the block. My regular expression is below, but it fails to find the string "Request timed out." What am I doing wrong?

if ($machine_status =~ /^Request timed out.$/m) {

Any help appreciated,

-T




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to