#!/usr/bin/perl -w use strict; my $fname = 0; my $lcnt = 0; my $state = 0; my $found = 0; while () { $lcnt++; if (/PTR_ERR/) { $state = 1; next; } if ($state == 0 || (/^[\r\n \t]+$/)) { next; } if (/^[ \t]*if[ ]*\(/) { if ($fname == 0) { print "File: ", $ARGV[0], "\n"; $fname++; } print "Found at $lcnt\n"; $found++; } $state = 0; } exit($found);