Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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 :-)


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]
[Discipulus]: what's? vote fairy is at seaside? cat got your tongue?

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2017-06-24 18:24 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (562 votes). Check out past polls.