Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Matching @ in string

by erroneousBollock (Curate)
on Nov 22, 2007 at 13:24 UTC ( #652365=note: print w/ replies, xml ) Need Help??

in reply to Matching @ in string

perl -e 'if ("h@t" =~ /(\@)/ ) { print $1 }'
"h@t" looks to Perl like you're trying to interpolate the array @t (the previous case doesn't because the quote ends the string early.

perl -e 'if ("h\@t" =~ /(\@)/ ) { print $1 }'


perl -e 'if (\'h@t\' =~ /(\@)/ ) { print $1 }'

should work fine.

Update: err, ooops :-)


Comment on Re: Matching @ in string
Select or Download Code
Replies are listed 'Best First'.
Re^2: Matching @ in string
by dwu (Monk) on Nov 22, 2007 at 13:28 UTC


    $ perl -e 'if (\'h@t\' =~ /(\@)/ ) { print $1 }' -bash: syntax error near unexpected token `('

    Not sure why - does escaping the single quote not work?

      Because the bash does not change anything in the -e ' .. ' string. And
      if (\'h@t\' =~ /(\@)/ ) {
      is no valid perl.
      And the -e string ends after if (\.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://652365]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2016-02-12 01:41 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (386 votes), past polls