I guess the tag is a variable, and it is checking for 9eaf – but does this exist in Perl?
What is the “=~” sign doing here and what are the “/” characters before and after 9eaf doing?
if ($tag =~ /9eaf/)
{
# Do something
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
=~is the operator testing a regular expression match. The expression/9eaf/is a regular expression (the slashes//are delimiters, the9eafis the actual regular expression). In words, the test is saying “If the variable $tag matches the regular expression /9eaf/ …” and this match occurs if the string stored in$tagcontains those characters9eafconsecutively, in order, at any point. So this will be true for the stringsand many others, but not the strings
and many others. Look up the ‘perlre’ man page for more information on regular expressions, or google “perl regular expression”.