Re: scalar / hash problem in HTML::Parser
- From: chas.owens@xxxxxxxxx (Chas. Owens)
- Date: Mon, 25 Feb 2008 09:55:27 -0500
On Mon, Feb 25, 2008 at 9:01 AM, Tim Bowden <tim.bowden@xxxxxxxxxxxxxx> wrote:
Making progress. Needed to understand hash references, and how tosnip
de-reference them.
Quick cheat ***:
#make a hash reference
my $ref = \%hash;
my $ref = { key1 => "val1", key2 => "val2" };
my $ref = { %hash };
#access a key
print $ref->{key1};
#access a slice
print join("\t", @{$ref}{qw<key1 key2>}), "\n";
#get all of its keys
my @keys = keys %{$ref}; #note, the {} are only necessary if $ref is a
complex expression
$ref can be any scalar value that hold a hash reference, so say you
have an array of hash refs named @foo, you can say
my @keys = keys %{$foo[0]};
to get the keys of the first element in @foo.
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
.
- Follow-Ups:
- Re: scalar / hash problem in HTML::Parser
- From: Tim Bowden
- Re: scalar / hash problem in HTML::Parser
- References:
- scalar / hash problem in HTML::Parser
- From: Tim Bowden
- Re: scalar / hash problem in HTML::Parser
- From: Tim Bowden
- scalar / hash problem in HTML::Parser
- Prev by Date: Re: scalar / hash problem in HTML::Parser
- Next by Date: Re: scalar / hash problem in HTML::Parser
- Previous by thread: Re: scalar / hash problem in HTML::Parser
- Next by thread: Re: scalar / hash problem in HTML::Parser
- Index(es):