develooper Front page | perl.perl6.users | Postings from December 2019

Re: modules and constants

Thread Previous | Thread Next
From:
Simon Proctor
Date:
December 6, 2019 09:39
Subject:
Re: modules and constants
Message ID:
CAGwa-jh=OE0zC31s9zUi5Z9gO7gRDMtZM6skccXhMGCw6NSJ5Q@mail.gmail.com
If you define them in the top level of your module then all your subs have
access :

constant FOO = 2;

sub inc-by-foo( $a ) {
  $a+FOO;
}

On Fri, 6 Dec 2019 at 09:05, ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2019-12-06 00:01, Tom Blackwood wrote:
> > Todd,
> >
> > AFAIK Perl’s culture is not to use so many constants in actual
> > programming. :)
> >
> > Tom
> >
>
> Is there a way to make constants universal inside a module, or
> do I have to declare them inside every sub?
>


-- 
Simon Proctor
Cognoscite aliquid novum cotidie

http://www.khanate.co.uk/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About