Hi,
What am i missing on line 16, when I run this I get
Search pattern not terminated at count-scr.pl line 16
#!perl open(my $log, ">log-subnet.txt") or die "Could not open log: $!\n"; ##### Step 1, read subnetsopen(my $in, "<names.txt") or die "Could not open names.txt: $!\n";while(<$in>) { next unless /(.*?)\/(.*)$/; my $subnet = $1; print "Checking $subnet\n"; my @dnsoptions = `./object.exe -u Xxx-p Xxx -b $subnet -o rich`; my %counts; foreach my $line (@dnsoptions) { my @f = split/"\s+", $line; $counts{$f[3]}++; } print $log "For subnet $subnet:\n"; foreach my $k (keys %counts) { print $log " $k: $counts{$k}\n"; }} close($log);
Thanks
fixed format:
Any idea on what I am missing? regarding the error I get
Search pattern not terminated Line 16
#!perl
open(my $log, ">log-subnet.txt") or die "Could not open log: $!\n";
##### Step 1, read subnets
open(my $in, "<names.txt") or die "Could not open names.txt: $!\n";
while(<$in>) {
next unless /(.*?)\/(.*)$/;
my $subnet = $1;
print "Checking $subnet\n";
my @dnsoptions = `./object.exe -u Xxx-p Xxx -b $subnet -o rich`;
my %counts;
foreach my $line (@dnsoptions) {
my @f = split/"\s+", $line;
$counts{$f[3]}++;
}
print $log "For subnet $subnet:\n";
foreach my $k (keys %counts) {
print $log " $k: $counts{$k}\n";
}
}
close($log);
The syntax of the split command is:
1. split /PATTERN/,EXPR,LIMIT
2. split /PATTERN/,EXPR
3. split /PATTERN/
4. split
(It splits the string EXPR, considering PATTERN as the delimiter, with LIMIT being the max. number of fields EXPR is split into.)
So, the line no. 15 of your script should be changed thusly:
my @f = split/"\s+"/, $line;
or
my @f = split/\s+/, $line;
Hope that helps,
tyler_durden