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

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:
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 |

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://305877]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2018-02-25 01:40 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (312 votes). Check out past polls.