Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: <FILE> Questions

by Chady (Priest)
on Nov 10, 2003 at 14:42 UTC ( #305877=note: print w/ replies, xml ) Need Help??


in reply to <FILE> Questions

There's a lot of wierd stuff going on in here, I'm not sure I got this right, but let's try.

In your second example, you use $_content where I see a $content read from the db. then you perform your substitution on $_ where you should have done it -- I assume -- on $content, $content =~ s/{{([a-zA-Z0-9\{\'\}_]+)}}/ eval ($1) /ge;

OTOH, I think it's safer/better(?) to use a hash instead of evaluating strings. So instead of doing s/{{([a-zA-Z0-9\{\'\}_]+)}}/ eval ($1) /ge; you would do s/{{([a-zA-Z0-9\{\'\}_]+)}}/$hash{$1}/g; - but I don't know the context of this, so I can't judge.

does this actually run? what errors does it produce?

Update: I re-read your question, namely this part:

What if that is in a database, and instead of it having $string it has {{string}} and I normally do a s/{{string}}/$string/g;
That would work if you do it like so:
s/{{([^}]+)}}/${$1}/g;
unless you're using strict refs.

He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

Chady | http://chady.net/


Comment on Re: <FILE> Questions
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-10-22 02:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls