in reply to Substitution in Perl

Please, enclose your code in <code> ... </code> tags.

It is impossible to make head or tails of your post.

Also, did you actually run that code? What were your expectations and what did actually happen?

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: Substitution in Perl
by nasreen (Initiate) on Oct 21, 2010 at 06:11 UTC

    What does the following lines mean?

    sub getTargets { #getTargets($makeInfoRef->{$makeId}{cmd}) my $arg = $_[0]; my $cmd = $arg; $cmd =~ s/.*&amp;&amp;\s*\w*make //; $cmd =~ s/^\w*make //; $cmd =~ s/-+[\w-]+=?\s*[\w\.\:\;\\\/]*\s+//g; my @tmp = split(/\s+/,$cmd); return @tmp; }

    Actually the "cmd" variable has

     "emake --emake-cm=aceaagent01.mw.na.cat.com --emake-emulation=gmake --emake-root=Y:\; --emake-autodepend=1 --emake-tmpdir=d:\temp --emake-clearcase=vobs --emake-annodetail=file --win32 --keep-going -f Makefile_a4e4i3_serv_test_a4 --emake-class=BE_CM --emake-build-label=BE_T4F_ALPHA_6_BASE_2_ECJob39384 --emake-annofile=serv_test_a4_anno.xml --emake-historyfile=serv_test_a4_emake.data -B lib"

    So finally what wil be returned by that sub function? Can anyone explain me the logic behind this fuction?

      The routine finally returns "lib".

      It does so by deleting a lot of things which --for whatever reason-- are not considered interesting. Roughly speaking it throws away everything except words that are not preceded by "-" (minus) or "=" (equal), and are not a form of "make".

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        Wow!!! Great yeah... Thank you so much!!!