in reply to Printing just the file name for all the cases
#!/usr/bin/perl -w use strict; while (my $line = <DATA>) { if ( my $include_file = ($line =~ /#include\s+[<"](.*?)[>"]/)[0] ) { print "$include_file\n"; } } #prints: #string.h #stdlib.h #sys/dispatch.h __DATA__ INPUT:- #include "string.h" --> below code prints header this is just a BS, nonsense line #include <stdlib.h> --> below code prints header #include <sys/dispatch.h> --> not able to get the header name(dispatc +h.h)
|
|---|