Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Re: Re: How to use variables from other package?

by chromatic (Archbishop)
on Apr 27, 2003 at 19:55 UTC ( [id://253520]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: How to use variables from other package?
in thread How to use variables from other package?

I'm not sure I understand. Perl can indeed check variable names at compile time, even if they're fully qualified. Create a file called Foo.pm:

package Foo; use vars qw( $foo ); $foo = 1;

Use it within a test program like so:

#!/usr/bin/perl -w use strict; use Foo; print "$Foo::foo\n"; print "$Foo::fooo\n";

This gives me:

Name "Foo::fooo" used only once: possible typo at usefoo.pl line 7. 1 Use of uninitialized value in concatenation (.) or string at usefoo.pl + line 7.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: How to use variables from other package?
by integral (Hermit) on Apr 27, 2003 at 20:01 UTC

    I forgot about warnings. Sometimes they can be easily missed (I certainly have), so reading the 'Fatal Warnings' section of perllexwarn may be an idea.

    use warnings FATAL => qw(all);

    --
    integral, resident of freenode's #perl
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2025-01-25 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (70 votes). Check out past polls.