my $msg;
open(IN, "<", "$0") or die "Can't open $0 - $!";
while (<IN>) {
$msg = $msg . $_;
}
close IN;
$count = () = $msg =~ /\n/g;
print "Line Count - $count\n";
#or
$lines = () = $msg =~ m/\n/g;
print "Line Count - $lines\n";
open(IN, "<", "$0") or die "Can't open $0 - $!";
while (<IN>) {
$msg = $msg . $_;
}
close IN;
$count = () = $msg =~ /\n/g;
print "Line Count - $count\n";
#or
$lines = () = $msg =~ m/\n/g;
print "Line Count - $lines\n";