Filling up layout 
Author Message
 Filling up layout

I have a layout file something like this

--- CUT ---
<P>Here's $word[1] $word[2] $randomvar</P>
--- CUT ---



 print "$line";

Quote:
}

But the output is "<P>Here's $word[1] $word[2] $randomvar</P>". Is there any
way to assing those variables? Using s// is too slow (there's ~100 variables
in my layout.)

---
Markus Haikonen, Tampere University of Technology
WWW: http://www.*-*-*.com/ ICQ: 129846722 Tel: +358505369575

-Kertokaapa jotain taustastanne.
-Noh, valmistuin p??aineena k?ytett?vyys
-HOHOHOHOHO!



Sun, 16 May 2004 17:44:07 GMT  
 Filling up layout

Quote:

> I have a layout file something like this

> --- CUT ---
> <P>Here's $word[1] $word[2] $randomvar</P>
> --- CUT ---



>  print "$line";
> }

> But the output is "<P>Here's $word[1] $word[2] $randomvar</P>". Is there any
> way to assing those variables? Using s// is too slow (there's ~100 variables
> in my layout.)

First off, you should consider using one of the standard HTML template
systems.

If you don't want to do that and want to allow your layout file to
contain arbitrary Perl interpolation:


  chop( my $line_processed = eval "<<__EOD__\n$line\n__EOD__\n" );
  print $line_processed;

Quote:
}

Be aware that "arbitrary Perl interpolation" includes stuff like:

--- CUT ---

--- CUT ---

I recommend that if you are going to use this technique you actually
put the variables that you want to be able to substiute in a separate
package namespace and then use the Safe module's reval() function
rather than simple eval() to evaluate the template.

Please now sign up to my campaign to have this technique included in
the FAQ "How can I expand variables in text strings?"

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Sun, 16 May 2004 20:45:17 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Pop Ups

2. UPS calculation problem using qcostcgi.cgi script.

3. New module UPS::Nut

4. UPS shipping code???

5. UPS shipping API problems

6. UPS Shipping cgi/perl script needed

7. Incorporating UPS shipping cost automatically

8. Business::UPS

9. UPS Tools

10. Perl script for UPS listening

11. Pop Ups

12. UPS realtime shipping rates

 

 
Powered by phpBB® Forum Software