Hi, I can't seem to figure out why this code won't work
I have the ip address in the file ipfile.txt, but I keep getting guest not found is there something I am over looking?
#!/usr/bin/perl -w
my (@ipfconts, $ipfile, $x);
$remote_addr = '63.103.135.132';
$ipfile = '../ipfile.txt';
open (IPFILE, "<$ipfile")
|| die("Could not open $ipfile: $!\n");
@ipfconts = <IPFILE>;
for ($x=0; $x<=$#ipfconts; $x++) {
if ($ipfconts[$x] =~/$remote_addr}/){
print "added new guest!\n";
last;
}else{ print "guest not found!\n";last; }
}
In reply to for loop
by s0ttle