Without concatenating the data lines, or using a subhash on the hash, is there a way I can keep all that data keyed together?
Is there some reason why you need to avoid concatenating the data lines, or using a multi-level hash? Because I think either of those (actually both) would suit what I think you want... fever's point about joining the regexes seems like a very plausible place to start:
Did I draw the right conclusions about your data? Does this break some condition that you left out of your post? (update: fixed indentation)foreach $line(@urllist){ $data = get($line); if ( $data =~ m!$regex1\r?\n$regex2!io ) { $school->{school} = $1; ($school->{school}{addr}, $school->{school}{city}, $school->{school}{zip}, $school->{school}{phone}, $school->{school}{level}) = ($2,$3,$4,$5,$6); } # might the two lines show up in reverse order? then elsif ( $data =~ m!$regex2\r?\n$regex1!io ) { $school->{school} = $3; ($school->{school}{addr}, $school->{school}{city}, $school->{school}{zip}, $school->{school}{phone}, $school->{school}{level}) = ($4,$5,$6,$1,$2); } else { next } print join $/, $school->{school}, map{$school->{school}{$_}} qw/addr city zip phone level/; print $/; };
In reply to Re: Question on anon hashes
by graff
in thread Question on anon hashes
by Popcorn Dave
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |