I am very Unix-oriented. Part of my pipeline of creating and spitting SQL at a database consisted of this script:
#!/usr/bin/perl # whither strict? # use Text::Template? Template? HTML::Template? @in_data = qw(table id_field email_field state_field zip_field dob_fie +ld); sub USAGE { "Usage:\n\t$0 @in_data"; } @ARGV == @in_data or die USAGE; eval "\$$in_data[$i++] = '$_'" for @ARGV; print <<EOSQL SELECT $id_field, $email_field, $state_field, $zip_field, $dob_field FROM $table WHERE $zip_field like '336%' or $zip_field like '335%' or $zip_field like '346%' or $zip_field like '337%' or $zip_field like '342%' EOSQL

Now this was nice, but I did not want to cut and paste the top (the argument specs and the argument verification) into each and everyone of my SQL generator scripts.

So, here is my second incarnation

#!/usr/bin/perl # whither strict? # use Text::Template? Template? HTML::Template? use lib '/home/tbone/perl-modules/lib/perl5/site_perl/5.6.1'; use Text::Template::Script qw(table id_field email_field state_field zip_field dob_field); warn $table; __DATA__ SELECT $id_field, $email_field, $state_field, $zip_field, $dob_field FROM $table WHERE $zip_field like '336%' or $zip_field like '335%' or $zip_field like '346%' or $zip_field like '337%' or $zip_field like '342%'

And this is fine, but the DATAsection of the caller module is not getting passed

This node had a couple of solutions but neither worked. Presumably because the DATA filehandle is not open yet... is there anyway to get at the DATA section of a calling module in the import() section of another?

Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality


In reply to Getting the DATA section of one module in the import() of another by princepawn

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!
  • 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, details, 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, summary, 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.