in reply to string manipulation

my $new = join ':', grep{ m[^/users/ctbld] } split ':', $ENV{path};

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: string manipulation
by Noame (Beadle) on May 18, 2008 at 12:37 UTC

    Thanks.

    Another question in the same issue: I have the following initialization
    CPP_PROJ=/nologo /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "_LIB" /D "_F +P_BKLIB" /D "_MBCS" /D "FTLIB" /D "_AFXDLL" /D "WIN32" /FR"$(I NTDIR)\\" /Fp"$(INTDIR)\ApplicationObject.pch" /YX /Fo"$(INTDIR)\\" /F +d"$(INTDIR)\\" /FD /GZ /c

    I need to match all the strings start with /D "_<any_string" to variable and replace "/D" with "-D" so finally the new variable should to be like:
    $NEW_VAR = "-D_ DEBUG -D_LIB -D_FP_BKLIB -D_MBCS - DFTLIB …"
    Please advice. Thanks again
      (my @d) = $str =~ m!/D\s+"([^"]+)"!g; my $var = join " ", map{"-D$_"}@d;

        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.