Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How do I escape '#' pound sign?

by Anonymous Monk
on Sep 08, 2000 at 07:04 UTC ( [id://31535]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How do I escape '#' pound sign?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I escape '#' pound sign?
by ariels (Curate) on Feb 21, 2001 at 19:27 UTC
    Inside a regular expression (given the section we're in):
    $x = '# a comment'; print "$&\n" if $x =~ m/^\#.* # A comment! /x;
    (You have to backwhack the #, or m//x will consider it a comment.
Re: How do I escape '#' pound sign?
by ariels (Curate) on Feb 21, 2001 at 19:26 UTC
    Inside a regular expression (given the section we're in):
    $x = '# a comment'; print "$&\n" if $x =~ m/^\#.* # A comment! /x;
    (You have to backwhack the #, or m//x will consider it a comment.

    Originally posted as a Categorized Answer.

Re: How do I escape '#' pound sign?
by Anonymous Monk on Sep 08, 2000 at 13:01 UTC
    Simply by putting the pound inside quotes:
    $val = q(#); $val2= "#";
Re: How do I escape
by merlyn (Sage) on Sep 08, 2000 at 07:12 UTC
    Where would you need to escape it? {grin}

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://31535]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-26 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found