Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Problem with ampersand and regex

by roboticus (Chancellor)
on Dec 19, 2012 at 22:25 UTC ( #1009653=note: print w/replies, xml ) Need Help??


in reply to Re^2: Problem with ampersand and regex
in thread Problem with ampersand and regex

The '@' isn't a problem when you read it from a file. Only if you're using it in a double-quoted string. For example:

$ cat t.pl #!/usr/bin/perl use strict; use warnings; my @array = <DATA>; foreach my $line (@array) { if ($line =~ /mail: /) { my $mail = substr($line, $+[$#+] ); print "mail=$mail\n"; } } __DATA__ This @ should be just fine mail: this @ should also be fine $ perl t.pl mail=this @ should also be fine

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009653]
help
Chatterbox?
belg4mit kicks Perl in the shins, "Unmatched ) in regex; marked by" my ass
[belg4mit]: Nothing wrong with perl -le 'print ":)" =~ /(?^u:^(\:|\:\))$) /'
[Lotus1]: belg4mit are you on a Linix server?
[belg4mit]: yes. the regular expression is generated in code from a text file. that s the regular expression that Perl blows up when it reaches it, but if I use it from the comman line it's fine

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2017-04-25 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (459 votes). Check out past polls.