function or operator to ignore metacharacters like +

Hi,
I have this line that I have problem with..

s/$tmpvar//mgi;

The problem is sometimes $tmpvar = "annotationmarking +",
with metacharacters. Is there a regx option or perl function
that ignores metacharacter. Or should I go ahead and
parse my input for metacharacters and add a \ infront of it.

Thanks.

JP
kelly [ Di, 03 Januar 2006 20:48 ] [ ID #1125677 ]

Re: function or operator to ignore metacharacters like +

kelly wrote:
>
> s/$tmpvar//mgi;
>
> The problem is sometimes $tmpvar = "annotationmarking +",
> with metacharacters. Is there a regx option or perl function
> that ignores metacharacter.

Yes.

perldoc perlre

perldoc -f quotemeta

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Hjalmarsson [ Di, 03 Januar 2006 21:11 ] [ ID #1125678 ]

Re: function or operator to ignore metacharacters like +

kelly wrote:

> I have this line that I have problem with..
>
> s/$tmpvar//mgi;
>
> The problem is sometimes $tmpvar = "annotationmarking +",
> with metacharacters. Is there a regx option or perl function
> that ignores metacharacter.

Yes. Read the relevant documentation on Regexps at
perldoc perlre
and search for \Q and \E

> Or should I go ahead and
> parse my input for metacharacters and add a \ infront of it.

No.

Paul Lalli
Paul Lalli [ Di, 03 Januar 2006 21:23 ] [ ID #1125679 ]

Re: function or operator to ignore metacharacters like +

In article <43BAD575.3020507 [at] some.com>, kelly <kelly [at] some.com> wrote:

> Hi,
> I have this line that I have problem with..
>
> s/$tmpvar//mgi;
>
> The problem is sometimes $tmpvar = "annotationmarking +",
> with metacharacters. Is there a regx option or perl function
> that ignores metacharacter. Or should I go ahead and
> parse my input for metacharacters and add a \ infront of it.
>
> Thanks.
>
> JP
>

You are posting the same messages independently to alt.perl and
comp.lang.perl. Please do not do that. I already wasted my time
responding to one of your posts in comp.lang.perl that was already
answered by Paul in alt.perl. If you must post to both groups, post one
message to multiple groups (cross-post).

And as I explained before, comp.lang.perl is defunct. Please do not
start threads there.

Thanks.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Jim Gibson [ Di, 03 Januar 2006 22:33 ] [ ID #1125680 ]
Perl » alt.perl » function or operator to ignore metacharacters like +

Vorheriges Thema: open remote file without modules
Nächstes Thema: editing a file using per script