whaledawg has asked for the wisdom of the Perl Monks concerning the following question:

When i use the function &gmtime() in my regular perl programs it works fine, but when i try and incorporate it into a .pm file it says its undefined. Could it have anything to do with the fact that i have it symbolicaly linked into one of the @INC directories? do i have to change @INC to point directly at gmtime.pm? and if i do, how does one change @INC? I need help with a quickness

Replies are listed 'Best First'.
Re: This bites
by ase (Monk) on Jun 20, 2000 at 11:38 UTC
    I may not be understanding the question fully but, since gmtime() is a Perl built-in... I doubt that @INC is the source of your problem. Is the name of your module gmtime.pm? Does your module define a gmtime subroutine? Maybe an example of the offending code would shed some more light on the problem.

    I did just notice you said &gmtime() ... that would mean that gmtime must be a subroutine defined somewhere as

    sub gmtime() { #do something }
    I did a quick test with the following...
    #!/usr/bin/perl print scalar gmtime,"\n"; print &gmtime;
    which yielded:
    Tue Jun 20 00:52:23 2000
    Undefined subroutine &main::gmtime called at ...blah blah

    ase
    I try to help more, realize how little I know. Who is real student? -(my perlmonk haiku for the day)

Re: This bites
by ase (Monk) on Jun 20, 2000 at 12:12 UTC
    I think what you mean is "gmtime() is a function (a built-in). If perl thinks it's a subroutine and that subroutine is not defined, then perl goes loopy."

    Glad to have helped.

RE: This bites
by whaledawg (Novice) on Jun 20, 2000 at 12:01 UTC
    you are correct sir. the answer is that gmtime is not a function, it is a built-in and if perl thinks its a function than it goes loopy. thanks
Re: This bites
by chromatic (Archbishop) on Jun 21, 2000 at 08:30 UTC
    Looks like you're trying to dereference gmtime() in package main::. You're in main:: by default, and you're not specifying a package for it. The builtin Perl functions live in package CORE::.

    If you really need to specify the whole address of a core function, try &CORE::gmtime. (I usually don't use the &subroutine-name syntax, as I think subroutine-name() looks better.)