Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

RE: Re: Dreaming of Post Interpolation

by BBQ (Curate)
on May 30, 2000 at 04:24 UTC ( [id://15330]=note: print w/replies, xml ) Need Help??


in reply to Re: Dreaming of Post Interpolation
in thread Dreaming of Post Interpolation

Yes, regex... But would that be considered true interpolation?

The idea of searching within word boudaries for a string starting with \$ occured to me several times, but I have always thought of it as not being very practical. Let me put it this way (this time with math):
$n = 1; $m = $n*2; $o = $m*2; $s = "$n $m $o\n"; print $s; $n = 2; print $s; ^d 1 2 4 2 4 8
Sure this is a simplistic example (as was my previous), but what when you have 1000+ more lines of code, wouldn't it be alot easier to control? Is the only way out to run a regex after assignment? There must be another way... Think of the possibilities!

Am I suffering from fuzzy-logic syndrome?

Replies are listed 'Best First'.
RE: RE: Re: Dreaming of Post Interpolation
by takshaka (Friar) on May 30, 2000 at 04:54 UTC
    I forgot about the double-e substitution ( ie, s/(\$\w+)/$1/gee ). You can do that with lexicals.

    No matter what, you end up doing some sort of substitution and/or eval. In the second example you want to re-evaluate $m=$n*2 whenever $n is reassigned, which isn't possible without creating more complex data structures. That's far different from interpolating variables into a string.

      I'm sorry, but I don't see why its different at all! As a matter of fact, in both cases, I have variables in a string. The contents of those variables should change later on, but not the string itself! I could agree that there are different approaches to each (basically because on deals with numbers and the other with text) but that doesn't mean that the presented wish changes.

      Had I defined $person and $adjective (with different values) before the string, then both would be practically the same examples.

      I don't think I've done a good job of explaining what I was thinking about, and I am starting to think that interpolation doesn't quite get the idea through. Referencing is closer as a term, but it has already been defined, and I don't beleive it comes close to what I wish perl would do either. Its fustrating to try and explain a concept that doesn't have any good examples (that I can provide at least).

      Nevertheless, thanks for the input!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 06:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found