in reply to Printing just the file name for all the cases

use strict; use warnings; use File::Basename; while (my $line = <DATA>) { if ($line =~ /#include [<"](\S+\.h)[>"]/) { print basename($1), "\n"; } } __DATA__ #include "string.h" --> below code prints header #include <stdlib.h> --> below code prints header #include <sys/dispatch.h> --> not able to get the header name(dispatch +.h)