On Thu, Feb 14, 2002 at 10:40:20AM -0500, Chas Owens wrote:
> On Thu, 2002-02-14 at 10:19, Martin A. Hansen wrote:
> >
> > hi
> >
> > i have inherited this piece of code and i have been wondering hard about how i can
>print the different @records returned from the subroutine? im not even sure whats on
>my hand here. is this a hash of arrays or a hash of array references? and how do i
>unwind those?
> >
> >
> >
> > martin, beginning perl.
> >
> >
> >
> >
> > my @records = &parse_pubmed_fcgi( [ qw(UI AU TI TA VI IP PG DA) ] );
> >
> >
> > ###################### subroutines ####################
> >
> >
> > sub parse_pubmed_fcgi {
> >
> > my ( $keys ) = @_;
> >
> > my ( @records, $record, $record_id, $line, $key );
> >
> > my %wants = map { $_ => 1 } @{ $keys };
> >
> > while ( defined ($line = <>) ) {
> > chop $line;
> >
> > if ( $line =~ /^(UI)\s*-/ ) {
> > $key = $1;
> >
> > if ( $record ) {
> > push @records, $record;
> > undef $record;
> > }
> > }
> >
> > if ( $line =~ /^([A-Z]+)\s*-\s*(.+)/ ) {
> > $key = $1;
> > push @{ $record->{ $key } }, $2 if $wants{ $key };
> > }
> > elsif ( $line =~ /^\s+(\S.*)/ ) {
> > $record->{ $key }->[-1] .= " $1" if $wants{ $key };
> > }
> > }
> >
> > push @records, $record if $record;
> >
> > if ( wantarray ) {
> > return @records;
> > } else {
> > return \@records;
> > }
> >
> > }
> >
>
> Data::Dumper is your friend. If you have a data structure and you don't
> know what is in it just say:
>
> print Dumper(\@Records);
>
> and bingo the data structure is printed out to the screen.
>
> --
> Today is Setting Orange the 45th day of Chaos in the YOLD 3168
> Kallisti!
>
> Missle Address: 33:48:3.521N 84:23:34.786W
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
ok, if Data::Dumper is my friend, how can i print all record fields of type AU only?
martin
--
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]