Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
No such thing as a small change
 
PerlMonks  

Re^6: needing to zip files in a series that begin with the same IP address

by diamondsandperls (Beadle)
on Jul 27, 2012 at 22:32 UTC ( #984111=note: print w/ replies, xml ) Need Help??


in reply to Re^5: needing to zip files in a series that begin with the same IP address
in thread needing to zip files in a series that begin with the same IP address

Thanks for your help. I am having trouble nailing that part just right i have tried several zip calls but the code is failing. Thanks for the heads up on Modern::Perl I was curious of what the module was doing.

here is what seems to be the best educated guess

#!perl use Modern::Perl; use IO::Compress::Zip qw(zip $ZipError) ; my %files; my @files = <*.txt *.docx>; for (@files) { next unless /^(\d+.\d+.\d+.\d+)/; push @{ $files{$1} }, $_; } for my $ip ( keys %files ) { my $output = "$ip.zip"; do { zip => $output, $ip -> $_ } for @{ $files{$ip} }; }


Comment on Re^6: needing to zip files in a series that begin with the same IP address
Download Code
Re^7: needing to zip files in a series that begin with the same IP address
by Kenosis (Priest) on Jul 27, 2012 at 22:55 UTC

    Remember to check for any return errors when zipping. Also, you can pass an array reference to zip, so try the following:

    for my $ip ( keys %files ) { zip \@{ $files{$ip} } => "$ip.zip" or die "zip failed: $ZipError\n +"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://984111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-04-17 00:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (436 votes), past polls