Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gb-swatanabe/6239241 to your computer and use it in GitHub Desktop.
Save gb-swatanabe/6239241 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
my (%s) ;
$s{ "999999999999" } = '';
while (<>){
if( /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ ){
# IPアドレスが含まれている行
my $k = sprintf("%03d%03d%03d%03d",$1,$2,$3,$4) ;
if( defined $s{$k}){
$s{$k} .= $_ ;
} else {
$s{$k} = $_ ;
}
} else {
# そうでない行
$s{"zzzzzzzzzzzz"} .= $_ ;
}
} # end of while
# 出力
foreach (sort keys %s){
printf( "%s", $s{$_} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment