Re: General Perl/Web questions
- From: lgrinberg@xxxxxxxxx (Leonid Grinberg)
- Date: Fri, 28 Apr 2006 10:21:43 -0400
Yeah, what that would pretty much mean is that you will make a file
called, say, CommonFuncts.pm and then in each Perl script say
use CommonFuncts;
Alternatively, you can make a common_functs.pl file, where each one of
the above actions is performed in a subroutine (the file should only
have subroutines, and should not do anything outside of them (except
like use strict;)) and then, from within each file, you could do
something like
BEGIN
{
do ('common_functs.pl');
die if $@;
}
The BEGIN just makes the block be loaded at the beginning of
execution, the do() function loads files and eval()s them (except
since all we have are subroutines, nothing is actually performed, you
just now have all of the new subroutines to work with) and the 'die if
$@' exits if there were syntax errors in the common_functs.pl file and
it prints them.
Either of the two ways work, I just prefer do();
Cheers!
--
Leonid Grinberg
lgrinberg@xxxxxxxxx
http://www.lgrinberg.org
.
- Follow-Ups:
- Re: General Perl/Web questions
- From: Chad Perrin
- Re: General Perl/Web questions
- From: Randal L. Schwartz
- Re: General Perl/Web questions
- References:
- General Perl/Web questions
- From: Steve Gross
- Re: General Perl/Web questions
- From: JupiterHost.Net
- General Perl/Web questions
- Prev by Date: Re: simple wildcard regex problem.
- Next by Date: Re: Chomp method
- Previous by thread: Re: General Perl/Web questions
- Next by thread: Re: General Perl/Web questions
- Index(es):
Relevant Pages
|
|