Hi, I've got two programs, lets say "main.cgi" and "commons.pl". The "commons.pl" program contains all of the globably declared variables and subroutines that are used by all the other various programs, including "main.cgi".
In the commons file, I also have my "use" statements.
#!/usr/bin/perl
use DBI;
use Date::Calc qw( Decode_Date_US Add_Delta_Days);
use File::Copy;
use LWP::Simple;
use CGI::Carp 'fatalsToBrowser';
use CGI qw/:standard/;
$q = new CGI;
my $variables;
etc...
From the "main" program, I'm accessing this large group of subroutine and variable by using:
#!/usr/bin/perl
require ("commons.pl");
rest of program here...
Now, the problem is that I'm getting "Prototype mismatch: sub main::head ($) vs none at /usr/local/lib/perl5/5.00502/CGI.pm line 232." errors everytime I run the script.
I've tried to define the "commons" as a .pm and "use commons", but then I get errors like "Undefined subroutine CGI::"
So, the question is how do I create a package of common variables, arrays, hashes, and subroutines in one file that I can call either through require or use and have them available to all my other programs.
--
Filmo the Klown
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.