hks_turbokits has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl script that uses html that i have written and i want to include a up to date copy of an text file to be printed onto the page when it loads How do i do this? Print {./textfilename.txt}??
  • Comment on Print Entire Text File to Perl Script/Html

Replies are listed 'Best First'.
Re: Print Entire Text File to Perl Script/Html
by jeffa (Bishop) on Dec 11, 2008 at 14:58 UTC

    I realize that using a Templating system or Website Authoring system is daunting when first learning web programming, but consider that you could accomplish this with HTML::Template like so:

    <TMPL_INCLUDE NAME="textfilename.txt">

    In HTML::Mason like so:

    <& textfilename.txt &>

    And in Template like so:

    [% INCLUDE textfilename.txt %]

    And for the record, PHP makes this just as easy. I find it ironic that people complain about Perl losing market share to PHP when very few mentors seem to nudge newbies to use these modules and let instead let them continue using Perl in a very non web savey way.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      when very few mentors seem to nudge newbies to use these modules and let instead let them continue using Perl in a very non web savey way.
      Those newbies can't distinguish between server-side and client-side, don't know what is HTTP/CGI; templates are too complicated for them.

        Then watch them switch one by one to PHP. If you don't want to be part of the solution, then for God's sakes don't add to the problem.

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
Re: Print Entire Text File to Perl Script/Html
by CountZero (Bishop) on Dec 11, 2008 at 14:16 UTC
    What have you written so far?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: Print Entire Text File to Perl Script/Html
by Anonymous Monk on Dec 11, 2008 at 13:10 UTC