Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Qualified module variables and arrays

by trippledubs (Deacon)
on Sep 18, 2014 at 02:51 UTC ( [id://1100991]=note: print w/replies, xml ) Need Help??


in reply to Qualified module variables and arrays

In the beginning of a Perl Romance, your skills will get better every hour you spend learning and writing perl, similar to Moore's law. So, every time you look back at your past work, you are always disappointed. The beauty and nature of Perl is so that, you will solve your problem now, and that is a beautiful thing, and you will also recognize more problems that Perl can solve and will keep coming back.

It is always best to post some compilable code here so we get an idea of the context of your question. Here are some random ways to call subroutines and I think the pitfalls become evident of bad design choice. The principles are: have very descriptive and appropriate variable names, and keep your namespace as uncluttered as possible. And, as in life, always do whatever you want. Counter example follows

#!/usr/bin/env perl package a; use strict; use warnings; use lib (','); sub double { return 2*$_[0]; } package main; use strict; use warnings; use feature 'say'; use Cowbell qw(thrice); sub double { return "$_[0]" . $_[0]; } sub twice { return a::double($_[0]); } say a::double(2); #4 say double(2); #22 say thrice(2); #6 say thrice(2) - twice(3) + double(22) + 1;
#!/usr/bin/env perl package Cowbell; use strict; use warnings; use Exporter 'import'; our @EXPORT_OK = qw (thrice); sub thrice { return 3*$_[0]; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-29 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found