It sounds like you want something like this:
#!/usr/bin/perl use warnings; use strict; use Socket; my $hostfile = '/tmp/jn/hosts'; my $logfile = '/tmp/jn/logforthisserver.log'; open HOSTFILE, '<', $hostfile or die "Cannot open '$hostfile' $!"; my %unique_ips; while ( <HOSTFILE> ) { next if /^(?:#|\s*$)/; my $ip = inet_aton( ( split )[ 0 ] ); $unique_ips{ $ip }++; } close HOSTFILE; open LOGFILE, '>', $logfile or die "Cannot open '$logfile' $!"; for my $ip ( sort keys %unique_ips ) { print LOGFILE inet_ntoa( $ip ), "\n"; } close LOGFILE;
In reply to Re: removing a column
by jwkrahn
in thread removing a column
by jn64024
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |