in reply to Custom Module question

The mainOne (thanks davido ;-) problem is, that sub printname lives in the package printname::. Your main program lives in the package main::. To access sub printname() from your main program, you either need to access it like so printname::printname("John") or by exporting sub printname() from package printname:: into package main::. The latter allows it to work as you expected in your example. The module Exporter helps you to import the prinname::printname() to main::printname(). BTW, lowercase package names are reseved for pragmas.

An introduction to writing modules can be found in perlmod, etc.

Replies are listed 'Best First'.
Re^2: Custom Module question
by davido (Cardinal) on Dec 03, 2014 at 21:45 UTC

    That may be the main problem in the code he posted, but it's not the problem he's seeing when he runs his program (which must not be identical to what is posted), or he would have asked about that rather than the warning. However, the reason for the warning he asks about in his question is pretty easy to spot.

    :)

    Update: GrandFather correctly pointed out that I missed the second message, and thus didn't notice that one of his problems is the failure to either export or fully qualify the function.


    Dave