in reply to Re: $_ and nested while loops w/angle operator
in thread $_ and nested while loops w/angle operator
(Continued.)
My code, above, will create a Hash-of-Arrays in %data. When it's done, you can iterate over the data set using code like the following:
Of course, the possibilities are endless; so if you are having trouble working with the data once you've read it in, we'd be happy to help.for my $query( sort keys %data ) { # get all the lines of the query at once, into an array: my @query_lines = @{$data{$query}}; # or iterate over them: for my $qline ( @{$data{$query}} ) { # ... do something with the line. } # or, if you really care about the line numbers: for my $li ( 0 .. $#{$data{$query}} ) { my $qline = $data{$query}[$li]; print "query $query, line $li: $qline"; } }
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: $_ and nested while loops w/angle operator
by alienhuman (Pilgrim) on Apr 08, 2004 at 17:06 UTC | |
by jdporter (Paladin) on Apr 08, 2004 at 19:50 UTC |