> > --- Dan Muey <[EMAIL PROTECTED]> wrote:
> > > #!/usr/bin/perl -w
> > > use strict;
> > > #my $dog = 'bart';
> > > eval {
> > >         use lib '/home/dmuey';
> > >         require "lib.lib";
> > > };
> > > print "Content-type: text/html\n\n";
> > > print "Error: $@ :: $dog ::\n";
> > > 
> > > :: lib.lib file is ::
> > > 
> > > my $dog = 'joe';
> > > 1;
> > 
> > First, $dog is a my() variable, and so ONLY exists in the lib 
> > file. Don't use my() in that circumstance.
> 
> Makes sense.
> Thanks! I got it going ok and it was good to know before I 
> made a whole bunch of stuff that would've needed changing!
> 
> Thanks again.!

You're very welcome.
 
> > better, try this:
> > 
> > libfile:
> > =========
> > $dog = 'spot';
> > 
> > progfile:
> > =========
> > use warnings;
> > use strict;
> > use vars '$dog';
> > do 'libfile';
> 
> Just curious...Why do, why not require ??
> 
> > print "$dog\n";
> > 
> > output:
> > ========
> > spot
> > 
> > c.f. do() in the docs. :)
> > 
> > perldoc -f do

Personally, because I like typing 2 letters instead of 7. :)

Seriously, see the docs, which say that require() 
  "...demands that a library file be included if it hasn't 
   already been included. The file is included via the do-FILE
   mechanism, which is essentially just a variety of eval."

If it might already have been included, use require() to prevent
re-work. If not, save the extra behind-the-scenes stuff (and the typing
of 5 letters! :)

In *most* every case, however, I recommend use() and a module.
I don't think I've ever written anything that used a do() or a
require(), to be honest. I've written some things that could have been
shorter and done sooner if I *had*, but always preferred the extra work
to make it modular *once*, so that I wouldn't have that problem again.

Still, that was my situation -- yours might warrant the do(). :)

TMTOWTDI!
  

__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to