#!perl #use strict; use warnings; use IO::Compress::Zip qw(zip $ZipError) ; my @textfiles = <*.txt *.docx>; foreach my $textfile (@textfiles) { if ($textfile =~ /(\d+.\d+.\d+.\d+.*)/) { my $ip = $textfile =~ /(\d+.\d+.\d+.\d+).*/; my $files; push @{$files{$ip}}, $textfile; zip $textfile => $output or die "zip failed\n"; } }