Hi Dov,
On Tuesday 31 August 2010 12:47:10 Levenglick Dov-RM07994 wrote:
> Hi,
> Although this is bound to be the oldest question in the book, how do I
> perform the C equivalent of #include "defines.h" in Perl 5.12
> I want to have a separate file that will define variables accessible to
> all parts of my script. If it makes the answer any easier, they can
> become environment variables (i.e. inserted into %ENV).
>
You can define package-scope variables using something like:
[code]
# Define a variable:
our $pi = 3.141592;
our $num_days_in_year = 365;
# And then wherever:
sub hello
{
my $r = shift;
print "You have a circle with a circumeference of ", (2 * $::pi * $r),
"\n";
}
[/code]
Even modules (that can be loaded using "use", "require", etc.) can define such
package scope variables.
Regards,
Shlomi Fish
>
> Best Regards,
> Dov Levenglick
>
>
> _______________________________________________
> Perl mailing list
> [email protected]
> http://mail.perl.org.il/mailman/listinfo/perl
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Why I Love Perl - http://shlom.in/joy-of-perl
God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl