#!/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)
In reply to Re: Printing just the file name for all the cases
by Marshall
in thread Printing just the file name for all the cases
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |