As someone has already mentioned
IO::Uncompress::Unzip has a filehandle interface that hides all the complexity of reading directly from a zip file.
Looking at the post from few days ago, the commented block below showed reading from the zip file
# my $sn=$fips2state->{$sfips}.'2010.sf1';
# my $zf=$dir0.'/sf1/'.$sn.'.zip';
# my $mf=$fips2state->{$fips}.'geo2010.sf1'; ;
# my $member=zipbyline_start($zf,$mf);
# while (my $line=zipbyline_read($member)){
# ... pull out datums AREALAND AREAWATR POP100, create density
# } # line
# zipbyline_close($member);
That would become this with IO::Uncompress::Unzip
use IO::Uncompress::Unzip;
my $sn=$fips2state->{$sfips}.'2010.sf1';
my $zf=$dir0.'/sf1/'.$sn.'.zip';
my $mf=$fips2state->{$fips}.'geo2010.sf1'; ;
my $member = IO::Uncompress::Unzip($zf, Name => $mf);
while (<$member>)
{
#... pull out datums AREALAND AREAWATR POP100, create density
}
close $member;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.