Hi to all,
Im currently testing and studying regular expression with splitting. Right now I have this code:
open my $infile, "<", "test.txt" or die "cannot open input: $!";
my @infile1= <$infile>;
close $infile;
foreach my $dns ( @infile1 ) {
chomp $dns;
if ($dns =~ /(dns:[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$
+/){
my ($ip, $dns1) = split /dns:/, $dns;
($ip) = split /,/, $dns1;
print "$ip";}
}
The test.txt contains the ff:
host1 dns:192.168.243.30,asdf
host2 dns:192.168.243.1,qwert
When I run the code it doesn't displayed anything... It seems the expression didn't matched... But when I tried changing the input file with only "dns:x.x.x.x" it matched.
Is there something missing with my code? Thanks so much..