Hi - 1) try: if ($reply[1] =~ /Connected/) { ... I _think_ w/o parens, Perl says: if $reply[1] => true true =~ /Connected/ => false (you also may have to have the m in m/Connected/
2) whole array: for (@reply) { if (/Connected/) { ... OK ... last; } } 3) after having read into a scalar: if ($reply =~ m/Connected/s) { ... 's' says search thru new lines. Aloha => Beau. -----Original Message----- From: Lance Murray [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 16, 2002 10:59 AM To: [EMAIL PROTECTED] Subject: SIMPLE regex expression comparison !! - What am I doing wrong? Hello I'm trying to write a simple script to test if a port is up or down. It all depends on being able to parse for the word "Connected" in an array. Try as I might, I can't figure out why the following regex comparison won't work. if $reply[1] =~ /Connected/ { The code snippet is as follows: #!/bin/perl $host = @ARGV[0]; $port = @ARGV[1]; @reply = `echo " " | telnet $host $port`; if $reply[1] =~ /Connected/ { print "Port is up\n"; else print "Port is down\n"; } If I comment out the if statement, and just print out the variables, I see what I'm expecting, e.g.: ... print $reply[1] Connected to ldsslcu151.chq.slc.ut.usa.wh.lds. My preference would be to parse the whole array for "Connected" and not just presume placement in any element. I tried storing the response to just a scaler (e.g., $reply = `echo " " | telnet $host $port`;), but I'm not sure how a scalar handles <cr> or <lf> characters. Anyway, the solution is probably obvious to someone, and I'd be really grateful if they'd share it. Lance ---------------------------------------------------------------------------- -- This message may contain confidential information, and is intended only for the use of the individual(s) to whom it is addressed. ============================================================================ == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]