@_ is indeed something perl groks natively (it's the argument list passed to a subroutine); and variables are interpolated into regular expressions. So, as written, your surmise about what's going wrong is correct; but shift those characters around (follow @ with anything else), and you probably wouldn't have seen just the problem you're seeing.

I don't see why perl would complain about an uninitialized value if the *only* change you made was escaping the @.

Now, to switch gears: this regex ain't gonna match email addresses. With the * following the character class it's just looking for ZERO OR MORE letters, digits, etc., so even "" is going to match.

Even if you change that * to a +, you're still not going to match anything like the range of valid email addresses "0", "@" all by themselves will match with that change.

There are lots of threads on this site about validating email addresses; matching the strings is a common thing people try to do in Perl, but there's no really simple way (see perlfaq9). That said, you might look into Email::Valid, Email::Find, or, if you really wanna do it with a regex, see the informative Re: pattern match e-mail addresses.

Philosophy can be made out of anything. Or less -- Jerry A. Fodor


In reply to Re: @ in regex, or not? by arturo
in thread @ in regex, or not? by JPaul

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.