Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to parse a template file

Posted on 1998-08-30
7
Medium Priority
?
198 Views
Last Modified: 2010-03-05
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.
0
Comment
Question by:freak022398
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1204602
while( <> ){
    s/(\$\w+)/$1/eeg;
    print;
}
0
 

Author Comment

by:freak022398
ID: 1204603
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
 
LVL 84

Expert Comment

by:ozo
ID: 1204604
$tmp =~ s/(\$\w+)/$1/eeg;
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:freak022398
ID: 1204605
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
 
LVL 84

Expert Comment

by:ozo
ID: 1204606
that's «=~» not «= ~»
0
 

Author Comment

by:freak022398
ID: 1204607
Great, thats it!
Now send an answer so you can get you'r points :)

Regards. Martin Møller.

0
 
LVL 84

Accepted Solution

by:
ozo earned 520 total points
ID: 1204608
$test =~ s/\$(\w+)/${$1}/g;
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question