#!/usr/bin/perl use strict; use Socket; my ( @hostcontents ,@uniquearray ,@ipaddresses ,@linesplit ,@line ) = (); my $line = (); my $hostfile = "/tmp/jn/hosts"; my %seen=(); my $logfile = "/tmp/jn/logforthisserver.log"; open(HOSTFILE,"<$hostfile"); foreach (){ if($_ =~ m/^#/){next;} if($_ =~ m/^\s$/){next;} push (@hostcontents,$_); } close(HOSTFILE); print "Current hostcontents:\n@hostcontents\n"; foreach my $temp (@hostcontents){ #print "my line is: $line"; #@linesplit = split($split,$line); #@linesplit = split(/\t+/,$line); #@linesplit = split(" ",$line); #@linesplit = split(/\s+/, $_)[0]; #print "Test:$line"; } #print "Current linesplit:\n@linesplit\n"; #foreach $line (@linesplit) { # next if $seen{$line}++; # push(@uniquearray,$line); # $seen{$line}++; # print"Seen Hash is:\n @{[ %seen ]}\n"; #} #Sort the array @uniquearray=sort(@uniquearray); #foreach my $line (@uniquearray){ # print "$line"; #SOCKET JUNK #} # open (LOGFILE,">$logfile"); # print LOGFILE (@ipaddresses); # close(LOGFILE); #}#end foreach