in reply to Can we use variable for pattern match and extraction

You are almost correct with the syntax; if you want to match a string against a regex, you will want to use
ABC: while () { #print "entered into while loop\n"; if ($_ =~ /$net_extract/) { $count = 1; print "hello\n"; }
-Mark

Replies are listed 'Best First'.
Re: Re: Can we use variable for pattern match and extraction
by Rex(Wrecks) (Curate) on Jun 26, 2002 at 20:17 UTC
    And the other thing that might be what you want is:
    ABC: while () { #print "entered into while loop\n"; if ($_ eq $net_extract) { $count = 1; print "hello\n"; }
    These are 2 quite different approaches though, kvale's will execute the loop if any part of $_ matches $net_extract, whereas the in the code above the loop will only execute if $_ and $net_extract match exactly.

    "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!
Re: Re: Can we use variable for pattern match and extraction
by ask_chinna (Novice) on Jun 26, 2002 at 21:59 UTC

    Mark,

    I am able to work now, with the following modifications.

    ^\*\|NET\smin_msb_led\0\, look at I have removed the starting and endig slashes.

    then "if ($_ =~ $net_extract)".

    -Chinna