Perl "test merge"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe Cosby

    Perl "test merge"


    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 !!$someperlvari able!!

    more text"

    and if $someperlvariab le = "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 $someperlvariab le)

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

    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

    Summoning his cosmic powers
    and blowing slightly from his toes
    the psychic emanations flow
    - Syd Barret

  • Joe Cosby

    #2
    Re: Perl "text merge"


    oops, that should have been "text merge"



    --
    Joe Cosby

    "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

    Comment

    • Joe Cosby

      #3
      Re: Perl "test merge"


      D'OH!

      Text::Template was what I was looking for

      Sorry for the newbie question/s

      --
      Joe Cosby

      EMBRACE the SUCKINESS

      Comment

      Working...