I've used the example you provided, and it works beautimously. However, I'm wondering if there's a better way to avoid having to repeat these same variable names four times as you can see below (once in the main program and three times in the nc_library.pm package). I have about twenty-five in all, so it would be nice not to have to constantly synchronize them (not to mention the fact that I've also got to put them in HTML::Template for a TMPL_VAR loop thingy). Any ideas? Thanks!

#my second_page.pl: #!/usr/local/bin/perl5_8 use strict; use warnings; use nc_pswd; use nc_library; use vars qw/ $titlebar $rpt_no $rpt_lbl $rpt_name $rpt_asofdt $project $proj_re +f $attr_dept $attr_descr $attr_award $attr_prog $attr_projpd $attr_f +yr $attr_budgpd $attr_fund $attr_rate $attr_subclass $attr_status $attr_spec $attr_equip $attr_resp $attr_pi $rpt_type $from_act_tbl $from_bud_tbl /; use HTML::Template; use DBI; use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser); #remove for PRD my $CGI = CGI->new; #clear buffers and set up web page (required) $|=1; print $CGI->header; &call_vars; #and do other stuff.... # --------------------------------------------------------------- # #my nc_library.pm package nc_library; use strict; use warnings; use Exporter (); our @ISA = 'Exporter'; our ( $titlebar, $rpt_no, $rpt_lbl, $rpt_name, $rpt_asofdt, $project, $proj_ref, $attr_dept, $attr_descr, $attr_award, $attr_prog, $attr_projpd, $attr_fyr, $attr_budgpd, $attr_fund, $attr_rate, $attr_subclass, $attr_status, $attr_spec, $attr_equip, $attr_resp, $attr_pi, $rpt_type, $from_act_tbl, $from_bud_tbl ); our @EXPORT = qw/ call_vars commify dberror $CGI $spec_vars $titlebar $rpt_no $rpt_lbl $rpt_name $rpt_asofdt $project $proj_ref $attr_dept $attr_descr $attr_award $attr_prog $attr_projpd $attr_fyr $attr_budgpd $attr_fund $attr_rate $attr_subclass $attr_status $attr_spec $attr_equip $attr_resp $attr_pi $rpt_type $from_act_tbl $from_bud_tbl /; sub call_vars { use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser); #remove for PRD my $CGI = CGI->new; my $spec_vars = param('spec_vars'); ( $titlebar, $rpt_no, $rpt_lbl, $rpt_name, $rpt_asofdt, $project, $proj_ref, $attr_dept, $attr_descr, $attr_award, $attr_prog, $attr_projpd, $attr_fyr, $attr_budgpd, $attr_fund, $attr_rate, $attr_subclass, $attr_status, $attr_spec, $attr_equip, $attr_resp, $attr_pi, $rpt_type, $from_act_tbl, $from_bud_tbl) = split /~/, $spec_vars; return; } sub commify #Formats numbers (puts in commas) { local $_ = sprintf "%.2f", shift @_; 1 while $_ =~ s/^(-?\d+)(\d\d\d)/$1,$2/; return $_; } 1;

Lori


In reply to Re: Re: Re: Re: Re-calling in a list of variables into different .pl's by Lori713
in thread Re-calling in a list of variables into different .pl's by Lori713

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.