[Bioperl-l] Variable scope

Lincoln Stein lincoln.stein at gmail.com
Mon Oct 2 21:53:38 UTC 2006


Hi,

Read the documentation in Export. It is much better to formally export
constants, variables and functions and to import them with "use" than to use
"require". Also be sure that you understand how namespaces and modules work.

This is not a BioPerl topic and should have been directed to a general Perl
discussion list, such as Perl Monks.

Lincoln

On 10/2/06, ende <mmacho at gmail.com> wrote:
>
>
>         Hi
>
> this may be a typical perl topic and then out of this list center
> topic.  My apologize for any inconvenience.
>
> It is a annoying problem that is making me waste lot of time.
>
> I have a package with its new object, etc... and constants in it like:
>
> #-----
> use constant False => 0;
> use constant True => 1;
>
> our %CLRFG = (
>                PLASMIDO      => RED,
>                POLY_A        => GREEN,
>                RESTR_SITES   => BLUE,
>                CONECTORS     => MAGENTA,
>                CONTAMINANTS  => CYAN,
>            );
>
> our %CLRBG = (
>                PLASMIDO      => "",
>                POLY_A        => "",
>                RESTR_SITES   => "",
>                CONECTORS     => "",
>                CONTAMINANTS  => "",
>            );
> #------
>
> this constants are include with require "h.pl" from the main package
> file.
>
> I use this module from the mail command line driver to test it
> "using" it.  In the command line driver I can use with no gripe the
> constants False and True directly, for example "return True", etc
> without any reference to the origin of that constant.
>
> But, with respect to the variables (I would like they also were
> constants.. but how?), %CLRFG and %CLRBG I can't find the way of
> refering those int the module.  Finally I have desisted and _copy_
> the definitions where  I have needed it (in the sub were I print Ansi
> terminal colouring seqs...).  I don't find how to refer those
> variables out of the module.
>
> I have tried %modulename::CLRFG, for example, but Perl gives me errors.
>
> Any help?
>
>
>
>
> --
>      Juan Falgueras
>      Profesor del Depto. de Lenguajes y Ciencias de la Computación
>      Universidad de Málaga
>
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>



-- 
Lincoln D. Stein
Cold Spring Harbor Laboratory
1 Bungtown Road
Cold Spring Harbor, NY 11724
(516) 367-8380 (voice)
(516) 367-8389 (fax)
FOR URGENT MESSAGES & SCHEDULING,
PLEASE CONTACT MY ASSISTANT,
SANDRA MICHELSEN, AT michelse at cshl.edu




More information about the Bioperl-l mailing list