Hi Shawn,

On Wednesday 03 November 2010 09:27:14 shawn wilson wrote:
> i'm getting errors when trying to print these hash refs out and i just
> can't figure it out. here's the function:
> 
> for my $word ( keys %data ) {
>    while( my ($field, $type) = each %{ $data }{ $word } ) {
>       print "$word,$field" if( $type eq 'field' );
>       while( my ($line, $type) = each %{ $data }{ $word } ) {
>          print ",$line" if( $type eq 'line' );
>       }
>    }
> }
> 

1. each %{$data}{$word} is incorrect. You probably want:

each %{$data{$word}}.

And you may wish to do:

while (my ($word, $word_data) = each (%data)) {
        while (my ($field, $type) = each(%$word_data)) {

2. You are trying to iterate over %{$data{$word}} in two nested loops. This 
will confuse Perl to no end. What are you trying to do.

3. Some of what you're doing can be achieved using such functions as 
http://perldoc.perl.org/functions/grep.html .

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
What does "Zionism" mean? - http://shlom.in/def-zionism

<rindolf> She's a hot chick. But she smokes.
<go|dfish> She can smoke as long as she's smokin'.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to