Hi,

  I have not tried below code,  but I suggest you few more things here,

1) my $cmd = "perl -pi -e 's/aaa/bbb/g' ";    # you are are missing g
here.


 I doubht below command is working.
my $command =  $cmd.$file;   ## is concatenation operator required here.

Bit busy now meanwhile try aboove code changes , I hope some good
friends on this forum will solve query if  I won't find time.

 I will check the code, if I find sometime.

--
Regards,
Mustafa


________________________________

From: Chang Min Jeon [mailto:[email protected]]
Sent: Wednesday, May 13, 2009 2:05 PM
To: Mohammed Mustafa (WT01 - PES-Semi-Technology)
Cc: [email protected]
Subject: Re: use system() function


Hi mustafa

Thank you for your help.

I changed following code but it still doesn't work.

my $cmd = "perl -pi -e's/aaa/bbb/' ";

open(MAKEFILES, '<', $ARGV[0]) or die "file open error";
my @filelist = <MAKEFILES>;
foreach my $file (@filelist) {
    chomp($file);
    my $command =  $cmd.$file;
    print $command,"\n";
    my $result = `$command`;
    if($result) {
    print "success\n";
    } else {
    print "failed\n";
    }
}
close(MAKEFILES);

./Windowset/Common/Makefile.
gmk
perl -pi -e's/-+g -+dwarf2//' ./Windowset/Common/Makefile.gmk
: No such file or directory.mmon/Makefile.gmk
failed
./Windowset/Special/Makefile.gmk
perl -pi -e's/-+g -+dwarf2//' ./Windowset/Special/Makefile.gmk
: No such file or directory.cial/Makefile.gmk
failed



2009/5/13 <[email protected]>


        Hi Chang Min Jeon,

            Please use back stick operator here, instead of system
command, because system command doesn't return anything.

        Replace the system command with,

        $Result = `$command`;
        If ($Result) {
                  Print " appropriate message \n";
        } else {
                  print " Failed message \n";
        }

        --
        Regards,
        Mustafa


________________________________

        From: [email protected]
[mailto:[email protected]] On Behalf Of
Chang Min Jeon
        Sent: Wednesday, May 13, 2009 5:44 AM
        To: [email protected]
        Subject: use system() function


        hello

        I trying to modify file using perl one line like below.

        my $cmd = "perl -pi -e's/aaa/bbb/' ";

        open(MAKEFILES, '<', $ARGV[0]) or die "file open error";
        my @filelist = <MAKEFILES>;
        foreach my $file (@filelist) {
            chomp($file);
            my $command =  $cmd.$file;
            print $command,"\n";
            !system($command) or die "shell command not work";
        }
        close(MAKEFILES);

        but system function does not work.

        It print

        ./Windowset/Common/Makefile.gmk
        perl -pi -e's/-+g -+dwarf2//' ./Windowset/Common/Makefile.gmk
        : No such file or directory.mmon/Makefile.gmk
        ./Windowset/Special/Makefile.gmk
        perl -pi -e's/-+g -+dwarf2//' ./Windowset/Special/Makefile.gmk
        : No such file or directory.cial/Makefile.gmk

        someone who meet this problem?

        Thanks in advance
        --
        CashFlow
        To be rich.


        Please do not print this email unless it is absolutely
necessary.

        The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
addressee(s) and may contain proprietary, confidential or privileged
information. If you are not the intended recipient, you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately and destroy all copies of this message and any attachments.

        WARNING: Computer viruses can be transmitted via email. The
recipient should check this email and any attachments for the presence
of viruses. The company accepts no liability for any damage caused by
any virus transmitted by this email.

        www.wipro.com




--
CashFlow
To be rich.


Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to