Last Question :-)
I open file to read and should retrevie all the lines start with " SOURCE=.\" as display below:
SOURCE=.\ApplicationObject.cpp
SOURCE=.\BusinessObject.cpp
SOURCE=.\ClientObject.cpp
SOURCE=.\ComponentServer.cpp
SOURCE=.\main.cpp
SOURCE=.\posix_timer.cpp
SOURCE=.\ServiceServer.cpp
SOURCE=.\SystemObject.cpp
SOURCE=.\TestProgram.cpp
SOURCE=.\workflow.cpp
I need to initialize variable only with the file name, so finally I should have:
$fileLst=" ApplicationObject.cpp BusinessObject.cpp ClientObject.cpp ComponentServer.cpp"
My current code is:
foreach my $line (<MAKFILE>) {
chomp $line;
if ($line =~ m/SOURCE=\.\\(.*)$/i) {
push @fileLst, $1;
}
}
close MAKFILE;
$fileLst = join " ", @fileLst;
return $fileLst;
The final result includes garbage: "workflow.cppcppppppp".
Please advice.
Thanks.
|