in reply to Help with proper construction of callable scalars from a Module, please.

Perhaps not the sort of bone you want to chew on, but I would use one of the many existing template systems, with or without one of the website/application platforms, rather than write my own.

  • Comment on Re: Help with proper construction of callable scalars from a Module, please.

Replies are listed 'Best First'.
Re^2: Help with proper construction of callable scalars from a Module, please.
by taint (Chaplain) on Nov 13, 2013 at 06:38 UTC
    Good advice, and thank you ig.

    I hadn't actually intended to actually "re-invent the wheel". But rather, simply wanted to eliminate repeatedly re-typing the same lines, file, after file. So this idea seemed a simple solution -- combine all those blocks of (x)HTML in a Module. Then simply call them with short lines. In short; a great deal less typing.

    As to "one of the many existing template systems"
    I've yet to find one I actually like. But to each their own. :)

    Best wishes, and thanks for the honest reply.

    --Chris

    #!/usr/bin/perl -Tw
    use Perl::Always or die;
    my $perl_version = (5.12.5);
    print $perl_version;
      Revized edition:

      Seems in my initial frustration with accomplishing such a simple task. I ultimately overcomplicated matters. :(
      I think the following get's it right:
      pageblocks.pm

      use strict; package pageblocks; sub xmlheader { qq(<?xml version="1.0" encoding="UTF-8"?>\n); } sub xmldtd { qq(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http: +//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="application/xhtml+xml; ch +arset=utf-8" />\n); } 1; # polygraph
      and index.cgi
      #!/usr/bin/perl -wT # index.cgi print "content-type:text/html; charset=utf-8\n\n"; use strict; use lib ('./'); use pageblocks; print pageblocks::xmlheader(); print pageblocks::xmldtd(); print "<body> ... </body></html>";

      A big thanks to GrandFather, Jenda, and Anonymous Monk, for their thoughtful feedback.

      --Chris

      #!/usr/bin/perl -Tw
      use Perl::Always or die;
      my $perl_version = (5.12.5);
      print $perl_version;
        Crap! Next time I'll use PREVIEW first.

        ...and a big thanks also to ig!

        --Chris

        #!/usr/bin/perl -Tw
        use Perl::Always or die;
        my $perl_version = (5.12.5);
        print $perl_version;