I have this line
/Od /D "WIN32" /D "_DEBUG" /FD /EHa /MDd /Fo"Debug" /Fd"Debug\vc80.pdb" /W3 /c /Zi /clr /TP .\main.cpp"
And I want to extract the .\main.cpp
. I thought the following would do the trick:
if($string =~ /.*\s+(.*)$/i) {
print "matched ",$1,"\n";
}
because this same regex works in Ruby, and extracts the string I required. How can I get it working?
EDIT: here's how I setup my string:
for(find_indexes(\@lines,"/MDd")) {
my $actual_line = $lines[$_];
$actual_line = modify($actual_line,$additional_defs);
}
find_indexes
returns the indexes of lines matching any of the parameter following the array ref. The modify
sub will return a modified version of the string sent to it, containing some additional defines.
EDIT2: here's the modify
sub:
sub modify {
my $string = shift;
chomp($string);
my @defines = @_;
if($string =~ /.*\s+(\".*?)$/) {
my $match = $1;
print "match is $match";
my $string_copy = $string;
print "|$string_copy|\n";
}
}
The sub isn't complete, as I wasn't able to get it to work the way it should. I added an extra quote in the capturing group to force it to match the name. Something strange's happening though, I would expect the print of the $string_copy
to print the original string surrounded in |. However, I only get the leading pipe, not the ending one. I thought maybe Perl is interpreting the interpolated variable wrong, and I tried to do it like this:
print "|",$string_copy,"|\n";
but I still only get a leading pipe. This leads me to think something may indeed be wrong with the string. I can't think of anything else.