sandrider has asked for the wisdom of the Perl Monks concerning the following question:
I was wondering if there is a difference if you declare your module requirements at the beginning of your scripts or within a subroutine that uses it.
e.g.
use strict; use CGI; blah, blah, blah sub cgi { my $cgi = new CGI; blah, blah }
vs.
use strict; blah, blah sub do_cgi { use CGI; my $cgi = new CGI; blah, blah, blah }
2nd question; is there a difference if I declare usage for subroutine before getting passed variables in a subroutine?
e.g.
sub do_stuff { my $one, $two, $three = @_; use CGI; }
vs.
sub do_stuff { use CGI; my $one, $two, $three = @_; }
Question 3; I've realised that you can use modules in different ways e.g. use CGI or use CGI qw(:all). What is the difference?
Thanks.
Desmond
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: writing subroutines, differences in method of writing
by eibwen (Friar) on May 05, 2005 at 06:30 UTC | |
by etm117 (Pilgrim) on May 05, 2005 at 10:56 UTC | |
|
Re: writing subroutines, differences in method of writing
by revdiablo (Prior) on May 05, 2005 at 16:37 UTC | |
|
Re: writing subroutines, differences in method of writing
by sandrider (Acolyte) on May 07, 2005 at 01:28 UTC |