princepawn has asked for the wisdom of the Perl Monks concerning the following question:
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting the DATA section of one module in the import() of another
by jand (Friar) on Aug 14, 2003 at 23:27 UTC | |
by jand (Friar) on Aug 14, 2003 at 23:33 UTC | |
|
Re: Getting the DATA section of one module in the import() of another
by antirice (Priest) on Aug 14, 2003 at 23:42 UTC | |
|
Re: Getting the DATA section of one module in the import() of another
by bart (Canon) on Aug 15, 2003 at 13:52 UTC | |
|
Re: Getting the DATA section of one module in the import() of another
by graff (Chancellor) on Aug 16, 2003 at 22:05 UTC |