ag4ve has asked for the wisdom of the Perl Monks concerning the following question:
i'm trying to pull a slice out of a hashref of an arrayref and i'm failing. here's what i have:
print join(',', @{ $uword{ $seen{ $key }[ 1 ] }[ 1 .. $#{ @uword{ $see +n( $key ) } } ] } );
what perl is telling me is:
Global symbol "$seen" requires explicit package name at ./namevsfield. +pl line 105. syntax error at ./namevsfield.pl line 105, near "$seen( " syntax error at ./namevsfield.pl line 107, near "}" Execution of ./namevsfield.pl aborted due to compilation errors.
line 105 is above and line 107 closes my for my $key (keys %seen) { loop. these two variables were defined with:
andforeach my $string ( @word ) { if ( $uword{ $string }[ 0 ] == 1 ) { push @{ $uword{ $string } }, $line; next; } $uword{ $string }[ 0 ] = 1; push @{ $uword{ $string } }, $line; }
foreach my $string ( @data ) { # dedupe data and sanity check. next if !defined ($string); # should never be true. next if $seen{ $string }[ 0 ] == 1; # check %seen hash / array f +or dupe $seen{ $string }[ 0 ] = 1; # define hash of array and assign +check to it. $seen{ $string }[ 1 ] = $key; # add word from line to hash for r +eference. }
where i'm taking out dupes and appending where the data came from to a hashref of the hash. then i need to print out all of the data. i have no issues with posting the code if need be, i just didn't think it necessary. any help would be greatly appreciated. thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: error joining hashref of an arrayref
by Anonymous Monk on Oct 30, 2010 at 10:07 UTC | |
by ag4ve (Monk) on Oct 30, 2010 at 16:47 UTC | |
|
Re: error joining hashref of an arrayref
by choroba (Cardinal) on Oct 30, 2010 at 12:17 UTC | |
|
Re: error joining hashref of an arrayref
by Marshall (Canon) on Oct 30, 2010 at 12:26 UTC | |
by ag4ve (Monk) on Oct 30, 2010 at 16:37 UTC | |
by afoken (Chancellor) on Oct 31, 2010 at 07:12 UTC | |
by ag4ve (Monk) on Nov 01, 2010 at 04:37 UTC | |
by Marshall (Canon) on Nov 01, 2010 at 19:04 UTC |