Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Matching character

by vinoth.ree (Monsignor)
on Jul 21, 2013 at 14:47 UTC ( #1045512=note: print w/replies, xml ) Need Help??

in reply to Matching character

$str = "testing\"; $str =~ /\\$/;

All is well

Replies are listed 'Best First'.
Re^2: Matching character
by Lotus1 (Curate) on Jul 21, 2013 at 16:11 UTC

    This is easy to do when typing code directly into a node, you would catch this quickly but for the new monks:

    $str = "testing\";

    The backslash in this case will escape the double quote (") and with warnings turned on you get this:

    Can't find string terminator '"' anywhere before EOF at C:\b\perlmonks\regex\ line 4.

    Without warnings you get "Bareword found where operator expected at ..."

    use strict; use warnings; my $str = "testing\\"; print "matched!" if $str =~ /\\$/;

      Lol Lotus1

      You are right. I did not test. Thanks

      All is well

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045512]
[Corion]: Tabish: What are "tow" packages? Maybe you want to use PAR::Packer to copy them and your main program into one (ugly) script for distribution?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2017-12-11 09:52 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (288 votes). Check out past polls.