Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
After our CB convo, I decide to try to follow my own advice, this is what I got for
#!/usr/bin/perl use strict; use warnings FATAL => qw( all ); package my::site::Programs; sub get_data { my $self = shift; # not used but passed with '->' notation return q{This is a list of B<programs> that I am using or have use +d. I can not account for I<all> the software we have had and used ove +r the years. Some of it was so bad, we blanked it out of our heads. T +his list does not include a full list of hardware drivers either. So +much software, so little time or in this case patience.}; } 1; # not sure if this is actually needed here, but would be if you mov +ed this to a .pm that is "use"d or "require"d # replicate the functionality of the original package main; use CGI::Carp qw(fatalsToBrowser); use lib '../files/lib'; use Base::Page qw(page story); use Util::StoryMagic qw(program_magic); my $magic = program_magic; page( 'code' => sub { story(my::site::Programs->get_data(), { 'line ma +gic' => $magic }) }); # note you'll have to change how you handle wha +t was passed as "*DATA" # # NOTE, since you're now not using __DATA__ (via *DATA handle), you ca +n make the "main" content # minimal by passing in just the code reference: # # package main; # use lib '../files/lib'; # Base::Page->page( code => \&my::site::Program::get_data, story => q{ +Util::StoryMagic} ); #

The goal here was to show what I meant by making the catagory files into modules and to drop __DATA__. This offers no change to how things work now, but by converting all of your .pl files to a module internally, this sets you up for some things:

  1. incrementally put your data into module-like libraries
  2. move them to functional libraries by turning the above into a modulino - allows you to  use require q{../file/}, e.g.,
  3. once they work as they do now, but can be used us libraries as modulinos, you are free to experiment with Dancer2 or Mojo since they will fundamentally differ from your existing code being router/dispatch based and not file based (e.g., require content modules in the route handlers)
  4. then you can decide how to proceed, but this allows you to retain the functionality of the site now while exploring a more modern approach

Then eventually if you made them full libraries, you'd pull them into to the framework like:

# in framework route handing require q{path/to/}; my $data = my::site::Programs->get_data(); do something with $data

In reply to Re^2: Collapsing smaller scripts into a larger one, request for comment by perlfan
in thread Collapsing smaller scripts into a larger one, request for comment by Lady_Aleena

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (3)
    As of 2021-04-23 03:32 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found