Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

RE: RE: Re: Dreaming of Post Interpolation

by lhoward (Vicar)
on May 30, 2000 at 15:32 UTC ( [id://15380]=note: print w/replies, xml ) Need Help??


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

Unless I misunderstand what you're asking for; you can do the assignment multiple times with different values:
$text = sub { <<EOT; Dear $person, I know that this text is $adjective. But I wish it could be... EOT }; my @subs=('Mom:not interpolates', 'Dad:maybe interpolated', 'Sis:who knows'); foreach (@subs){ local ($person,$adjevtive)=split ':',$_; print &$text; }
My technique will also work for your number example (with everything stored as a function). However it look slightly ugly:
$n = sub {1}; $m = sub {&$n*2}; $o = sub {&$m*2}; $s = sub {&$n." ".&$m." ".&$o."\n"}; print &$s; $n = sub {2}; print &$s;

Log In?
Username:
Password:

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

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

    No recent polls found