in reply to Trying to create a common "variable library"
The low-tech solution would be
# the "variable library", e.g. MyVars.pm use vars qw($scalar @array %hash); $scalar = "Foo"; @array = qw(Foo Bar); %hash = (Foo => "Bar"); 1;
#!/usr/bin/perl -l use strict; use warnings; use MyVars; print $scalar; print "@array"; print "$_ => $hash{$_}" for keys %hash;
The ugly thing is (why I called it low-tech) that you have to mention all variables twice (because of the use vars) — but for "a dozen" variables this should be doable.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Trying to create a common "variable library"
by fullermd (Priest) on Jul 21, 2010 at 00:38 UTC | |
by almut (Canon) on Jul 21, 2010 at 05:03 UTC | |
by fullermd (Priest) on Jul 21, 2010 at 13:57 UTC | |
Re^2: Trying to create a common "variable library"
by ikegami (Patriarch) on Jul 20, 2010 at 23:42 UTC | |
by almut (Canon) on Jul 21, 2010 at 05:22 UTC | |
Re^2: Trying to create a common "variable library"
by tbblake (Initiate) on Jul 20, 2010 at 19:43 UTC |
In Section
Seekers of Perl Wisdom