For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > November 2005 > Re: grep mystery / What happened to my @ sign ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: grep mystery / What happened to my @ sign ?
John W. Krahn

2005-11-23, 6:56 pm

Jay Savage wrote:
> On 11/23/05, Jeremy Kister <perl-01@jeremykister.com> wrote:
>
> You want to be careful with your classes here. '@' is not a
> metacharacter inside a class ([]), so '\@' matches both a literal ''
> and '@'


Matches are interpolated as double quoted strings so you have to escape '@' if
it will be interpolated as an array.

$ perl -le'@. = @x = "A" .. "D"; print for qr/[@x]/, qr/[\@x]/, qr/[@.]/'
(?-xism:[A B C D])
(?-xism:[\@x])
(?-xism:[@.])



John
--
use Perl;
program
fulfillment
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com