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 |