Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

(jptxs)Re: Perl is psychic?!

by jptxs (Curate)
on Mar 06, 2001 at 05:06 UTC ( #62400=note: print w/replies, xml ) Need Help??


in reply to Perl is psychic?!

according to the Perl5 Pocket Ref, $& is the string matched by the last successful pattern match. Since your regex .* matches anything $& is set to that by the first line, which matches foo and that's what you print in your eval - it eval's $& and finds 'foo' there. I think... =)
"A man's maturity -- consists in having found again the seriousness one had as a child, at play." --Nietzsche

Replies are listed 'Best First'.
Re: (jptxs)Re: Perl is psychic?!
by MrNobo1024 (Hermit) on Mar 06, 2001 at 05:07 UTC
    Yes, but Perl dosen't set $& if you don't use it, and it was impossible to know that it would be used...
      Whoever voted down the above node completely missed the point. MrNobo1024 is completely correct in saying that if Perl worked as documented as far back as, say, Camel 2 then it should not have had enough information to calculate $&.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://62400]
help
Chatterbox?
[1nickt]: I have been an apostate in the Apple orchard for almost 15 years. But Dells are still high quality it seems, unlike Macs these days.
[1nickt]: And you can still configure the system at will, on the "Small Business" site.
[Corion]: 1nickt: I bought a 2015 XPS 13, which is a very nice and shiney (and somewhat overpriced) machine, but I think it's still better priced than an Apple machine. Now it just has to hold up 10 years like the old one did ;)
[1nickt]: Ah, you got Linus' fave? With Ubuntu? 4k display?
[1nickt]: ( The 17" monster I just bought is for my wife, who doesn;t leave the house with it...)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2017-03-27 13:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.