Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Undefined Subroutine & Global symbol requires explicit package name

by jaldama (Acolyte)
on Jan 24, 2012 at 16:27 UTC ( [id://949724]=note: print w/replies, xml ) Need Help??


in reply to Re: Undefined Subroutine & Global symbol requires explicit package name
in thread Undefined Subroutine & Global symbol requires explicit package name

Yikes, yeah I didn't realize that "Global Symbol...." error was due a declaring issue, I've always declared them with 'my' but forgot and should have thought that through more, yaddayadda.. With the undefined subroutine problem, my issue was resolved by adding use Socket; duhhh! So from my understanding, that type of error will come up if you try to call some type of function incorrectly, say I write INET_ATON instead of inet_aton, because perl is case sensitive, right? Orrr, in this case, not 'using' the Socket or a module perhaps? Thanks as always
  • Comment on Re^2: Undefined Subroutine & Global symbol requires explicit package name

Replies are listed 'Best First'.
Re^3: Undefined Subroutine & Global symbol requires explicit package name
by tobyink (Canon) on Jan 24, 2012 at 16:48 UTC

    Perl is mostly case-sensitive. There is some ambiguity over case with regard to module names on case-insensitive file systems. For example, given the following module:

    # this code is in Foo/Bar.pm package Foo::Bar; use parent qw/Exporter/; our @EXPORT = qw/baz/; sub baz { "Hello world"; } 1;

    On a Windows system (Windows a uses case-insensitive but case-preserving file system) you could do this:

    use 5.010; use strict; use foo::bar; say Foo::Bar::baz(); # says "Hello world"

    And you could do this:

    use 5.010; use strict; use Foo::Bar; say baz(); # says "Hello world"

    But you couldn't do this:

    use 5.010; use strict; use foo::bar; say baz(); # dies - undefined subroutine main::baz

    And you couldn't do this:

    use 5.010; use strict; use foo::bar; say foo::bar::baz(); # dies - undefined subroutine again
Re^3: Undefined Subroutine & Global symbol requires explicit package name
by lune (Pilgrim) on Jan 24, 2012 at 18:31 UTC
    You didn't really understand the first answer you got on the issue: "where did you find inet_aton documented?".

    When you call a subroutine, it must be defined somewhere, unless it is a builtin Perl function, like "each" and "print" in your example. In your code, you want to use functions from the module "Socket.pm" - so you have to "use Socket" to make these functions available.

    You can tell that inet_aton is not a Perl function simply by checking with man perlfunc or by trying

    perldoc -f inet_aton

    Of course, if you misspell a function you'll get the same error, but this is not the issue here.

    further documentation

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://949724]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2024-04-25 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found