Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

OVERVIEW:
I have an application where I am attempting to use a simple mechanism for inclusion (hereinafter 'inheritance' (used in a non-OOP, non technical sense)) of 'text blurbs' based on perl modules. The problem is how to persist the notion of 'inheritance' even after the perl code has been run or 'auto-generated'. The details are as follows. A code sample is below.

PROBLEM1:
How do you obviate the need to reproduce text blurbs in multiple places, when what you *really* want to do is inherit those text blurbs from a single, centralized source.

SOLUTION1:
Naive Inheritance solves Problem1. Simply define a MainModule that serves as a repository for all centralized text blurbs. Then include them from that MainModule whenever and wherever necessary.

PROBLEM2:
Naive Inheritance does not work with this particular application, because sometimes the perl source is 'auto-generated' and 'auto-republished'. This means that, from time to time, an identity transformation is applied to (for example) CustomerModule.pm, and the entire module code is 'refreshed' via automated process. This 'refresh' operation causes the inherited text blurbs to be 'flattened' into their plain text equivalents. This breaks the intended benefits of using inheritance.

QUESTION1:
What is a solution to fix Problem2 (the problem of Naive Inheritance) in which the variable values are replaced with their plain-text equivalent?
In order to illustrate the question, a simple example follows (portions omitted for space):

### begin: package CustomerModule ### ... ### ... ### begin node: ccPastDue30 %hDataRec = ( caption => 'Past Due 30 Days', domain => 'customer_corresp', codename => 'ccPastDue30', desc => 'for accounts that are 30 days late', keywords => 'customer warning deadbeat', ### ----------------------------------------------- body => q^ ^.MainModule::StandardHeader().q^ Dear __fname__ __lname__, It has come to our attention that your account is 30 days past due. Please address this oversight as soon as possible to avoid late fees and additional charges. Thank you. ^.MainModule::StandardFooter().q^ ^, ### ----------------------------------------------- ); do{my %hTemp = %hDataRec; $root->{$hTemp{mnemonic}} = \%hTemp; };### end_node ### begin node: ccPastDue60 ### ... ### ... };### end_node ### begin node: ccPastDue90 ### ... ### ... };### end_node
When the above code is run in 'output' context, we obviously want the 'StandardHeader' and 'StandardFooter' portions replaced with their plain-text equivalent. However, when the code is run in 'republish' or 'auto-generate perl' contexts, we do not want the StandardHeader or StandardFooter portions to be interpolated at all.
=oQDlNWYsBHI5JXZ2VGIulGIlJXYgQkUPxEIlhGdgY2bgMXZ5VGIlhGV

In reply to modules, auto generated code and content management by dimar

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (12)
    As of 2014-11-24 16:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (143 votes), past polls