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!
In reply to Re: needing to zip files in a series that begin with the same IP address
by Kenosis
in thread needing to zip files in a series that begin with the same IP address
by diamondsandperls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |