Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-04-19 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found