Ask a Question related to PERL Miscellaneous, Design and Development.
-
Jeff Thies #1
importing a hash from package
I'm sure this is easy, but I'm not finding it...
I have a package with a heash in it:
package VARIABLES;
my %HASH;
$HASH{a}='a';
$some_scalar='some_scalar'
....
I want to refer to that hash elsewhere.
I know I can do this:
my $local_some_scalar=VARIABLE::$some_scalar;
But, how do I get at HASH? Do I have to write a reference to it in
package VARIABLES?
Cheers,
Jeff
Jeff Thies Guest
-
What's up with the mx7 hash ?
CF Documentation says the Hash function in CFMX7 using the SHA algorithm generates a 28-character character string. Executing this code: ... -
hash of hash of array slices
This works Foreach ( @{$hash{$key1}{$key2}} ) This does note Foreach ( @{($hash{$key1}{$key2})} ) This gives me this error .... Can't... -
Sort a hash based on values in the hash stored as arrays of hashes
Hmm. I'm not quite sure if I got the subject right, but I'll try to explain. :-) I've got a hash of elements stored like this: $VAR1 = {... -
Hash of Hash
Greetings, I am attempting to make a hash of hashes or something equivalent but can't seem to get it working properly. Here is what I have so... -
Another reference question (hash of hash references)
beginners, I am trying to build a hash of hash references. My problem is that I need to be able to add a key/value pair to the internal hashes...... -
Steve Grazzini #2
Re: importing a hash from package
Jeff Thies <cyberjeff@sprintmail.com> wrote:
^^^^^^^^^^^^^^^^^^^^^^> package VARIABLES;
>
> my %HASH;
> $HASH{a}='a';
>
> $some_scalar='some_scalar'
>
> ...
>
> I want to refer to that hash elsewhere.
>
> I know I can do this:
>
> my $local_some_scalar=VARIABLE::$some_scalar;
That's not quite right.
The difference is between lexical (my) variables, which you can't> But, how do I get at HASH? Do I have to write a reference to it
> in package VARIABLES?
use outside the scope where they were declared, and package variables,
which are global.
You can use our() to declare package variables.
our %HASH; # %VARIABLES::HASH
Is that what you were after?
--
Steve
Steve Grazzini Guest
-
Jeff Thies #3
Re: importing a hash from package
Steve Grazzini wrote:oops!>
> Jeff Thies <cyberjeff@sprintmail.com> wrote:> ^^^^^^^^^^^^^^^^^^^^^^> > package VARIABLES;
> >
> > my %HASH;
> > $HASH{a}='a';
> >
> > $some_scalar='some_scalar'
> >
> > ...
> >
> > I want to refer to that hash elsewhere.
> >
> > I know I can do this:
> >
> > my $local_some_scalar=VARIABLE::$some_scalar;
Yes, thanks!>
> That's not quite right.
>>> > But, how do I get at HASH? Do I have to write a reference to it
> > in package VARIABLES?
> The difference is between lexical (my) variables, which you can't
> use outside the scope where they were declared, and package variables,
> which are global.
>
> You can use our() to declare package variables.
>
> our %HASH; # %VARIABLES::HASH
>
> Is that what you were after?
Jeff>
> --
> SteveJeff Thies Guest
-
Tad McClellan #4
Re: importing a hash from package
Jeff Thies <cyberjeff@sprintmail.com> wrote:
> Steve Grazzini wrote:>>> The difference is between lexical (my) variables, which you can't
>> use outside the scope where they were declared, and package variables,
>> which are global.
>>
>> You can use our() to declare package variables.
>>
>> our %HASH; # %VARIABLES::HASH
>>
>> Is that what you were after?
> Yes,
Then see also:
"Coping with Scoping":
[url]http://perl.plover.com/FAQs/Namespaces.html[/url]
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest



Reply With Quote

