CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
templates

 



SaiyanM
User

Nov 14, 2002, 3:51 PM

Post #1 of 3 (367 views)
templates Can't Post

I have a file, and want to change a word like this

<{[insert word here]}>

to the valuee of

$form{'[the insert word]'}



example


Code
   

<form method=post action=<{script_url}>

should return


Code
   <form method=post action=http://www.asdasd.com>

if $form{'script_url'} = http://www.asdasd.com


the code I'm trying to use is


Code
  $DATA[$i] =~ s/\<\{(.+)\}\>/$form{'$1'}/g;


instead of the value of $form{'[word]'} I get the actual word "$form{'[word]'} Mad

-------------
Whats 2 + 2 x 2?
Its not 8...
(Please Excuse My Dear Aunt Sally)...

(This post was edited by SaiyanM on Nov 14, 2002, 6:25 PM)


davorg
Thaumaturge / Moderator

Nov 15, 2002, 12:38 AM

Post #2 of 3 (354 views)
Re: [SaiyanM] templates [In reply to] Can't Post

You almost never want to put variables (like the $1 in your code) inside single quotes as they won't get expanded.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


SaiyanM
User

Nov 15, 2002, 4:36 PM

Post #3 of 3 (349 views)
Re: [davorg] templates [In reply to] Can't Post

I took the single quotes out and it worked

thanks

-------------
Whats 2 + 2 x 2?
Its not 8...
(Please Excuse My Dear Aunt Sally)...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives