use strict;

my $filename = shift @ARGV;
my %hashfile;
die "Can't open file '$filename': $!" if not  open(my $f,"<","$filename");

while(<$f>){
	chomp $_;
	#chomp - s default we can use this syntacsis - it's the same
	$hashfile{$_}++;
}

my $reg_exp= qr/((\d{1,2})|([0-1]\d{2})|(2[0-4]\d)|(2[0-5][0-5]))/;

my $reg_expX= qr/((\d)|([1-9]\d)|(1\d{2})|(2[0-4]\d)|(2[0-5][0-5]))/;

my $exp_ip= qr/(($reg_expX\.){3}$reg_expX)/;
my $exp2=qr/((\/)|(\/($exp_ip|(\d)|([12]\d)|(3[0-2])))){0,1}/;
my $reg_exp2= qr/^($exp_ip$exp2)$/;

#print "\n Reg EXp [".$reg_exp2."]\n";
#$_="128.159.255.245/32";


foreach(keys %hashfile){
	print "'$_' ";
	if ($_=~m/$reg_exp2/) {
    		print " Matches\n";
	} else {
	    print " Doesnt match\n";
	}
}


#$_=~m/^(((\d{1,2})|([0-1]{1}\d{2})|([2]{1}[0-5]{1}[0-5]{1}))\.){3}((\d{1,2})|([0-1]{1}\d{2})|([2]{1}[0-5]{1}[0-5]{1})){1}?/;

# ((\d{1,2}) | [0-1]\d{2} | [2][0-5][0-5])) {1} (\/ (\d{1}) | ([1-3][0-2]) ){0,1} /;
#print "res== [[".$1.";".$2." ]]\n";

#my $_="Happy new 2004 year";
#$_=~m/^.*(\d+) year$/;
#print "res== [[".$1." ]]\n";
#255.255.255.255/
#192.168.0.0/24
#341.0.0.0/33 - not valid
#<256 <256<256<256< 33
__END__
#пример файла:
125.125.125.98
255.5.6.5/5
4.4-4.-4.3
3.444.444.444/404
0.0.0.0
00.0.0.0
127.0.0.1/32
20.1.1.0/20
10.0.0.200/255.255.0.0
