Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://305877]
help
Chatterbox?
[james28909]: s/perl/per/
[james28909]: but i dont really know what your end goal is. if it works dont fix it lol
[Lady_Aleena]: james28909, I use get_data in a subroutine called movies.
[Lady_Aleena]: james28909, I put it at the top of my scratchpad, if you want to look at it.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2017-05-24 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?