On Saturday 08 April 2006 01:08, Alan_C wrote:
> On Friday 07 April 2006 03:34, John W. Krahn wrote:
> > Alan_C wrote:
> > > Hi,
> >
> > Hello,
>
> [ snip ]

> > #!/usr/bin/perl -w
> > use strict;
> >
> > @ARGV = glob 'xtst*';
> >
> > my %data;
> >
> > while ( <> ) {
> >     my ( $key, @keywords ) = split;
> >     if ( $key eq '#:' ) {
> >         for ( @keywords ) {
> >             push @{ $data{ $_ } }, $ARGV;
>
> what is the @{ $data  ??

$data{$_} contains a reference to an array.  It was automatically created when 
you tried to dereference it here @{$data{$_}}

so in essence @{$data{$_}} is an array.  Eventually each key in %data will be 
a keyword and the values will be the all the filenames where those keywords 
occurred.

map => [ xtst1234 xtst2345 ]
chomp => [ xtxt2345 xtxt3456 ]

> >             }
> >         }
> >     # quit looking when we reach the sixth line
> >     close ARGV if $. == 6;
> >     }
> >
> > for my $keyword ( keys %data ) {
> >     print "The keyword '$keyword' found in the files
> > @{$data{$keyword}}.\n"; }
>
> And, there it is again -- is that array of hash?  The rest of it I
> get/understand.

Here, he is again dereferencing the array reference in $data{$keyword} to spit 
out the contents of the array. 

>
> --
> Alan.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to