On 5/19/06, Umesh T G <[EMAIL PROTECTED]> wrote:
Hi List,

I am trying to grep a variable from a scalar value. Here is the example below.

$var = "mydisk";
$line = "mydisk is bad";

if (grep/\$var/,$line) {
    print "disk is not bad";
}
[snip]
TIA,

Cheers,
Umesh


As others have pointed out, get rid of the slash. But to go a little
further here, why are you using grep()? grep() is for lists, and you
don't have a list; $line is a scalar.

   if ($line =~ /$var/) {
       print "disk is not bad";
   }

See perlre or perlretut for details.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to