On Sat, Oct 24, 2009 at 11:25 PM, Shachar Shemesh wrote:
> Let me try to summarize what I understood from your excellent explanation:
if that works for you :-)
>
> All that is left is understanding why the round braces around the whole
> expression.
Oh, the syntax of foreach has those parenthe
Gabor Szabo wrote:
err, I don't think that "casting" is the right word to use here. What
{} does here is
disambiguates the expression.
Let me try to summarize what I understood from your excellent explanation:
Putting a modifier in front of a reference dereference it to the right
type ($ for
2009/10/24 Shachar Shemesh :
> Noam Rathaus wrote:
>
> Shachar,
>
> { } in Perl are casting when they surround a value
> And the second set of { } around the 'a' mean variable of Hash
>
>
>
>
> Grumble grumble grumble
not surprised as this is one of the funky places of Perl 5.
>
> Okay, I'm s
Noam Rathaus wrote:
Shachar,
{ } in Perl are casting when they surround a value
And the second set of { } around the 'a' mean variable of Hash
Grumble grumble grumble
Okay, I'm sorry for being difficult. I really couldn't find the answer
in the Perl documentation.
I understand the
Shachar,
{ } in Perl are casting when they surround a value
And the second set of { } around the 'a' mean variable of Hash
2009/10/24 Shachar Shemesh :
> Dov Grobgeld wrote:
>
> Noam beat me to it, but here's perl solution without additional variables:
>
> #!/usr/bin/perl
>
> %hash = (a=>['moo',
Dov Grobgeld wrote:
Noam beat me to it, but here's perl solution without additional variables:
#!/usr/bin/perl
%hash = (a=>['moo','goo','woo'],
foo=>3,
baz=>5);
$ref = \%hash;
foreach my $elem (@{$ref->{a}})
Hi Dov,
Yes, it works. Now can you, please, explain to me why? Wha
Noam beat me to it, but here's perl solution without additional variables:
#!/usr/bin/perl
%hash = (a=>['moo','goo','woo'],
foo=>3,
baz=>5);
$ref = \%hash;
foreach my $elem (@{$ref->{a}})
{
print "$elem\n";
}
Regards,
Dov
2009/10/24 Shachar Shemesh
> Hi all,
>
> $ref i
Sorry a mistake...
foreach my $ptrelem (keys %hash) {
Should be
foreach my $key (keys %hash) {
my $ptritem = %hash->{$key};
On Sat, Oct 24, 2009 at 7:55 PM, Noam Rathaus wrote:
> Hi Shachar,
>
> First you can always use Data::Dumper:
> use Data::Dumper;
> print Dumper($ref);
>
> To make sure
Hi Shachar,
First you can always use Data::Dumper:
use Data::Dumper;
print Dumper($ref);
To make sure that the data is stored correctly.
In regard to your question:
my $ref;
my %hash = %{$ref};
foreach my $ptrelem (keys %hash) {
my @array = @{$ptrelem};
foreach my $item (@array) {
print $it
Hi all,
$ref is a reference to a hash. Hash contains a component called "a"
which is an array. I would like to iterate all elements of said array.
I would like to do something along the lines of:
foreach my $elem @%$ref{a}
{
print "$elem\n";
}
Which, I think it clear, does not work. I also
10 matches
Mail list logo