in reply to Checking the include form and getting only the header name
#!/usr/bin/perl -w use strict; while (my $line = <DATA>) { chomp $line; if ($line =~ /#include [<"](\w+\.h)[>"]/) { print "file is: $1\n"; } } __DATA__ #include "string.h" #include <string.h>
Note that your usage of \w matches only one character — you'd need \w+ to match more than one. Also, you have the .h outside of the <...> or "...".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Checking the include form and getting only the header name
by Anonymous Monk on Mar 20, 2011 at 01:15 UTC | |
by Eliya (Vicar) on Mar 20, 2011 at 01:22 UTC | |
by Anonymous Monk on Mar 20, 2011 at 01:47 UTC | |
by Eliya (Vicar) on Mar 20, 2011 at 01:50 UTC | |
by Anonymous Monk on Mar 20, 2011 at 02:18 UTC | |
| |
by Anonymous Monk on Mar 20, 2011 at 01:19 UTC |