INPUT:- #include "string.h" --> below code prints header #include --> below code prints header #include --> not able to get the header name(dispatch.h) if ($line =~ /#include [<"](\S+\.h)[>"]/) { print "$1\n"; #not printing the header third case }