Connecting Tech Pros Worldwide Forums | Help | Site Map

what is "Quantifier follows nothing before HERE mark in regex m/* << HERE / "?

Newbie
 
Join Date: Jul 2007
Posts: 25
#1: Oct 16 '07
Hi All,

I am getting the following warning while running the perl script

Warning is:

Quantifier follows nothing before HERE mark in regex m/* << HERE /

Expand|Select|Wrap|Line Numbers
  1.  
  2. foreach(keys %hash) 
  3. {
  4.  
  5.     if($_ =~ /$arr[0]/)    // Here I am getting the above warning
  6.     {
  7.          $team = $hash{$myKeys[0]};
  8.  
  9.      }
  10.     else
  11.     {
  12.        $team = $hash{$myKeys[1]};
  13.    }
  14. last;
  15. }
  16.  
I am comparing the arr[0] with the first key.Why I am getting this?
can anybody help me?

Regards,
Bhavani

KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: Oct 16 '07

re: what is "Quantifier follows nothing before HERE mark in regex m/* << HERE / "?


$arr[0] has an asterisk at the beginning which is interpreted as a quantifier inside of a regexp. Use \Q...\E to escape meta characters in the string:

if ($_ =~ /\Q$arr[0]\E/)

see if that helps.
Newbie
 
Join Date: Jul 2007
Posts: 25
#3: Oct 17 '07

re: what is "Quantifier follows nothing before HERE mark in regex m/* << HERE / "?


Thankyou Kevin.
now It is working fine.
Reply