Hi Alec/Zak:

    see below

> Message: 6
> Date: Tue, 10 Mar 2009 09:45:37 +0800
> From: Alec Joseph Rivera <[email protected]>
> Subject: Re: [plug] Simple but Nutty Perl Problem (I think I'm blind)
>
> Perl has a B module and your module clashes with it. Try:
> 
> $ perl -I'.' x2.pl
> 
> Agi
> 
> On Monday 09 March 2009 11:20:52 pm Ludwig Isaac Lim wrote:
> > Hi:
> >
> >    Here is a simple problem that's driving me nuts. I swear, I read the
> > code n times already.
> >
> > ############### A. pm  #####################
> >
> > #!/usr/bin/perl
> >
> >
> > use Exporter;
> >
> > package A;
> >
> >
> > our @ISA=("Exporter");
> > our @EXPORT=qw(a);
> >
> > our $egg="ludwig";
> > sub a
> > {
> >         print "A...\n";
> > }
> >
> > return 1;
> >
> > ######################### B.pm ########################
> > #!/usr/bin/perl
> >
> >
> > use Exporter;
> >
> > package B;
> >
> > our @ISA=("Exporter");
> > our @EXPORT=qw(b);
> >
> > sub b
> > {
> >         print "b!...\n";
> > }
> >
> > return 1;
> >
> >
> > ######################## x2.pl ######################
> > #!/usr/bin/perl
> >
> > use B;
> > use A;
> >
> > print "${A::egg}\n";
> > a();
> > b();
> >
> > ###################### Output ###################
> >
> > [ora...@falcondev test]$ ./x2.pl
> > ludwig
> > A...
> > Undefined subroutine &main::b called at ./x2.pl line 8.
> >
> >
> >
> > Is there a good way of preventing this. I'm sure that EXPORT, ISA and
> > Exporter are spelled correctly!
> > I even run perl -cw on B.pm
> >
> 
> ------------------------------
> 
> Message: 7
> Date: Tue, 10 Mar 2009 11:13:00 +0800
> From: "Zak B. Elep" <[email protected]>

> On Tue, Mar 10, 2009 at 9:45 AM, Alec Joseph Rivera <[email protected]> wrote:
> > Hi Ludwig,
> >
> > Perl has a B module and your module clashes with it. Try:
> >
> > $ perl -I'.' x2.pl
> 
> Yes, Perl has the B:: namespace for modules that implement "backends",
> hence the name.  see `perldoc B'.
> 
> -- 
> Zak B. Elep  ||  http://zakame.spunge.org



     Thanks Alec, Zak! Sorry for the late reply, was putting 12 hours workweek. 
As an experiment,
I changed the module name, and it worked.

     Your answers lead me to think of some follow-up questions, namely:
     a) How do I prevent namespace collision like in my case? As I said I tried 
"use warnings, -w
flags", but it didn't me any warnings. There has to be an easier way than to 
memorize the names of
perl's standard modules :-)
     b) I tried putting a BEGIN{ Exporter::Verbose=1} (sorry if there is a 
typo, my Perl book is
at the office). The above BEGIN statement is supposed to verbosely list all the 
modules loaded
into your program. I saw "A" module loaded, but I didn't see the "B" module 
loaded (which
surprised me now, since there is a "B" module that comes along with perl.
    c) Is the Perl -I <dir> a standard practice for working with use defined 
modules? Any other
good practices? Sorry for the fishing expedition :-)

    Thanks guys! I learned a lot from you.

Regards,
Ludwig


      
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph

Reply via email to