Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Yet Another Variable Expansion Problem

by extremely (Priest)
on Apr 12, 2002 at 20:12 UTC ( #158659=note: print w/ replies, xml ) Need Help??


in reply to Yet Another Variable Expansion Problem

Well, if you would change the match to something like the following and have him stick all the variables in a namespace other than main:: you'd be better off than you are. The key trick is requiring a real word character after the '$'. $template =~ s/\[\$([a-zA-Z][\w\[\]\{\}'"]*)\]/'$Q::'.$1/eeg;

Basically, lop off the '$' too, make sure the first character is really a letter (and that one exists, yours allows [$] which isn't real good), and stuff that string onto a variable in another namespace.

If you are sure that every variable is a scalar you might just do /\[\$([a-zA-Z]+)\]/$hash{$1}/eg; as well.

And yes, I'm ashamed that I'm on the Template-Toolkit list and still helping you do this the wrong way. =) =)

++chromatic

--
$you = new YOU;
honk() if $you->love(perl)


Comment on Re: Yet Another Variable Expansion Problem
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2015-07-29 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls