Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Perl Modules

by hippo (Chancellor)
on Jun 20, 2017 at 15:53 UTC ( #1193155=note: print w/replies, xml ) Need Help??

in reply to Perl Modules

pls don't tell me to get a dang book. none of that stuff is at all helpful.

Try Ulysses - I think you'd enjoy it. (Edit: the parent post has subsequently been amended to introduce some formatting thus making this reference rather more obscure)

so i put "use pm::security;" at the top of my "" file. all's good so far, i think. building on my setup, i eventually come across things like "subroutine banned(...) is not defined". I'm like thinking how can that be. I STARE at my code and just can't figure out how "use pm::security;" in my "" module can say that "banned($$)" is not defined, when it's right here in the file! makes NO SENSE!

See Exporter or just call the sub via the full name eg: pm::security::banned ($foo, $bar)

Other things to read: perlmod and package. Also Coping with scoping.

Replies are listed 'Best First'.
Re^2: Perl Modules
by jamroll (Beadle) on Jun 20, 2017 at 17:43 UTC
    oh yes. i am using exporter, don't get me wrong there. always.

      Well, here's an SSCCE showing chained packages, one of which is an Exporter, the other not. Compare and contrast.

      #!/usr/bin/env perl use strict; use warnings; package pm::security; use Exporter; our @ISA = ('Exporter'); our @EXPORT = ('banned'); sub banned { print "Banned: @_\n"; } 1; package user; pm::security->import; # If in separate files, "use pm::security;" will + do. sub do_stuff { # We call banned without its package prepended because banned is # exported by package pm::security banned (@_); } 1; package main; # If in separate files, "use user;" here # We call do_stuff with its package prepended because do_stuff is not # exported by package user. user::do_stuff ('foo', 'bar');

      If your packages behave differently then you'll have to provide a similar SSCCE displaying the precise problem in order for others to help you get to the bottom of it.

        neat. i will pay attention to this SSCCE document from now as best i can.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2021-06-18 18:34 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (90 votes). Check out past polls.