How to parse a template file

How do i read a template file like this:
<IMG SCR=$pic.jpg>
<A HREF="$link">$text</A>
The $pic, $link and $text vars shouldt be changed to the
values they have in my perl program.
I have tried to read a file, line by line. And then use the
eval(); function, but that does not work :(
Please help me!

Regards Martin Møller.
freak022398Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ozoConnect With a Mentor Commented:
$test =~ s/\$(\w+)/${$1}/g;
0
 
ozoCommented:
while( <> ){
    s/(\$\w+)/$1/eeg;
    print;
}
0
 
freak022398Author Commented:
I can't get that to work :(
Or i don't know where to put it!

I have my template file in @temp, and i'm trying something like this:

foreach $tmp (@temp) {
#  This is where i need to find all $pic, $link, etc in $tmp.
#  and then insert the correct value i at that place.

  print "$tmp<BR>\n";
}

So how do i use you'r code within my foreach loop?

Regards. Martin Møller.

0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
ozoCommented:
$tmp =~ s/(\$\w+)/$1/eeg;
0
 
freak022398Author Commented:
It still won't work!

This code:
  $testa = "testing";
  $test = 'test=$testa';

  print "$test<BR>";
  $test = ~s/(\$\w+)/$1/eeg;
  print "$test<BR>";

makes this output:
  test=$testa
  4294967295

Where does that number come from? what an i doing wrong?

Martin Møller.

0
 
ozoCommented:
that's «=~» not «= ~»
0
 
freak022398Author Commented:
Great, thats it!
Now send an answer so you can get you'r points :)

Regards. Martin Møller.

0
All Courses

From novice to tech pro — start learning today.