Perl "test merge"

Discussion in 'Perl' started by Joe Cosby, Apr 10, 2004.

  1. Joe Cosby

    Joe Cosby Guest

    Thanks for all the help with the earlier questions I've posted

    I am trying to do something I've seen in other perl code bases but I
    don't know how they do it.

    You have a text -file- (html, usually) and it looks like this:

    "Some text

    Some more text !!$someperlvariable!!

    more text"

    and if $someperlvariable = "merge stuff" you end up with

    "Some text

    Some more text merge stuff

    more text"

    Now the point is, this should work for any variable defined in the
    parent code, not just the one particular one. (Obviously it would be
    easy if the only variable I had to worry about was $someperlvariable)

    If I define a string in perl as "some text $someperlvariable more
    text" then perl does what I want, the value of $someperlvariable goes
    into the string rather than "$someperlvariable".

    But if I load the string from a file this doesn't seem to work.

    It seems to be at least a somewhat common practice (using the double
    "!!" or other delimiters to indicate dynamic content to be merged in),
    it seems like I've seen it done in other code bases than the one I
    first saw it in.

    Does anybody know how to do this?

    --
    Joe Cosby
    http://joecosby.com/
    Summoning his cosmic powers
    and blowing slightly from his toes
    the psychic emanations flow
    - Syd Barret
     
    Joe Cosby, Apr 10, 2004
    #1
    1. Advertising

  2. Joe Cosby

    Joe Cosby Guest

    Re: Perl "text merge"

    oops, that should have been "text merge"



    --
    Joe Cosby
    http://joecosby.com/
    "So is it like a tree that falls in the forest with nobody there to hear it?"
    "I feel sorry for that tree" said Carter

    - Glen Gold
     
    Joe Cosby, Apr 10, 2004
    #2
    1. Advertising

  3. Joe Cosby

    Joe Cosby Guest

    D'OH!

    Text::Template was what I was looking for

    Sorry for the newbie question/s

    --
    Joe Cosby
    http://joecosby.com/
    EMBRACE the SUCKINESS
     
    Joe Cosby, Apr 11, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,829
  2. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Jan 23, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    313
    PerlFAQ Server
    Jan 23, 2011
  3. PerlFAQ Server
    Replies:
    0
    Views:
    703
    PerlFAQ Server
    Feb 3, 2011
  4. PerlFAQ Server

    FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?

    PerlFAQ Server, Feb 27, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    308
    PerlFAQ Server
    Feb 27, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    708
    PerlFAQ Server
    Apr 4, 2011
Loading...

Share This Page