in reply to needing to zip files in a series that begin with the same IP address
Perhaps the following will assist you with your coding:
use Modern::Perl; my %files; while (<DATA>) { next unless /^(\d+.\d+.\d+.\d+)/; chomp; push @{ $files{$1} }, $_; } for my $ip ( keys %files ) { do { say "Zip $_ -> $ip.zip" } for @{ $files{$ip} }; } __DATA__ 192.168.1.1somestring.txt 192.168.1.1anotherRANDOMstring.txt 192.168.1.1.somerandom.docx 192.168.1.3somestring.txt 192.168.1.3anotherRANDOMstring.txt 192.168.1.3.somerandom.docxx
Output:
Zip 192.168.1.1somestring.txt -> 192.168.1.1.zip Zip 192.168.1.1anotherRANDOMstring.txt -> 192.168.1.1.zip Zip 192.168.1.1.somerandom.docx -> 192.168.1.1.zip Zip 192.168.1.3somestring.txt -> 192.168.1.3.zip Zip 192.168.1.3anotherRANDOMstring.txt -> 192.168.1.3.zip Zip 192.168.1.3.somerandom.docx -> 192.168.1.3.zip
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: needing to zip files in a series that begin with the same IP address
by diamondsandperls (Beadle) on Jul 27, 2012 at 21:14 UTC | |
by Kenosis (Priest) on Jul 27, 2012 at 21:16 UTC | |
by diamondsandperls (Beadle) on Jul 27, 2012 at 21:21 UTC | |
by Kenosis (Priest) on Jul 27, 2012 at 22:22 UTC | |
by diamondsandperls (Beadle) on Jul 27, 2012 at 21:34 UTC | |
by Kenosis (Priest) on Jul 27, 2012 at 22:07 UTC | |
by diamondsandperls (Beadle) on Jul 27, 2012 at 22:32 UTC | |
|