#!/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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |