regex - simple Perl regular expression -


hi i'm quite new perl , seeking parse simple line of code.

what need parse in of

#include "filename" 

i need regular expression file name.

i know there's split method in python this, don't know if there's similar func in perl

thanks

you could split in perl:

my $fn = (split('"', $include_line))[1]; 

...but that's pretty obtuse way of going it. i'd opt for

my ($fn) = $line =~ /^#include +"([^"]+)"/; 

instead, clearer , has advantage of returning nothing on non-#include lines rather returning false positives if input file contains other lines double-quoted text.


Comments

Popular posts from this blog

C++: Boost interprocess memory mapped file error -

python - IO.UnsupportedOperation: Not Writable -

python - malformed header from script index.py Bad header -