[sf-perl] Net::Domain and system()

David Alban extasia at extasia.org
Mon Jan 29 19:41:42 PST 2007


Greetings,

A program I wrote uses a module I wrote.  The program uses system().  I saw:

    Ambiguous call resolved as CORE::system(), qualify as such or use
& at ... line ....

wtf?

I distilled it down to a simple example running on a machine with uname output:

  Linux myhost 2.4.21-47.0.1.ELsmp #1 SMP Fri Oct 13 17:56:20 EDT 2006
i686 i686 i386 GNU/Linux

and perl version:

  This is perl, v5.8.0 built for i386-linux-thread-multi
  (with 1 registered patch, see perl -V for more detail)

We also have:

  $ locate Domain | grep Net
  /usr/share/man/man3/Net::Domain.3pm.gz
  /usr/lib/perl5/5.8.0/Net/Domain.pm

The program is:

     1  #!/usr/bin/perl
     2
     3  use strict;
     4  use warnings;
     5
     6  use lib "/home/dalban/tmp";
     7
     8  use Foo::Bar;
     9
    10  # system "echo foo";
    11  # CORE::system "echo foo";

If line 10 is uncommented and line 11 is commented, I get:

  Ambiguous call resolved as CORE::system(), qualify as such or use &
at junk line 10.
  foo

If line 10 is commented and line 11 is uncommented, it works fine:

  foo

Here is Foo/Bar.pm:

     1  package Foo::Bar;
     2
     3  use strict;
     4  use warnings;
     5
     6  use Net::Domain;
     7
     8  get_hostname();
     9
    10  #-----------------------------------------------------------------------
    11  sub get_hostname {
    12    return Net::Domain::hostfqdn();
    13  } # get_hostname
    14
    15  #-----------------------------------------------------------------------
    16
    17  1;

The module and program are silly, but they reproduce the error I'm
seeing with the stuff I'm developing.

If I comment Bar.pm line 8 and run junk (the program calling it), I
don't get the error about resolving system().  If I substitute
Net::Domain::hostname() or Net::Domain::hostdomain on Bar.pm line 12,
I get the error also.

What am I missing?  Why does it seem like using the functions in
Net::Domain causes perl to be confused about calls to system()?

Thanks,
David
-- 
Live in a world of your own, but always welcome visitors.


More information about the SanFrancisco-pm mailing list