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?

Improve company productivity with a Business Account.Sign Up

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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.