Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: can we ever compile perl? Message-ID: <111032@convex.convex.com> Date: 13 Dec 90 20:59:28 GMT References: <9592:Dec920:40:5190@kramden.acf.nyu.edu> <110306@convex.convex.com> <1990Dec13.034336.21769@usenet@scion.CS.ORST.EDU> Sender: news@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 26 From the keyboard of pvo@sapphire.OCE.ORST.EDU (Paul O'Neill): :In article <110306@convex.convex.com> tchrist@convex.COM (Tom Christiansen) writes: :> eval "s/$find/$repl/g"; :Gee, I've always glossed over this eval stuff. Now that I'm paying attention :I'm befuddled. Why is the eval needed, Tom? :Why does the substitution 1/2 work w/o the eval? The $find is parsed and :found but the $repl gets shoved in literally. I just hate it when I don't :have a model that will predict code's behavior and have to "just try it" to :see what it does. Because perl only does one level of evaluation. If you want more, have you to ask for it. There are $1 and $2 references inside of $repl. :>Notice that I've used not one but two evals in this little program. :Boy, I am dense. Where's the other one? It's hidden in the substitute that creates repl: ($repl = shift) =~ s/[\s_]/'$'.++$i/eg; --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "With a kernel dive, all things are possible, but it sure makes it hard to look at yourself in the mirror the next morning." -me