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 <mohammed.must...@wipro.com> > 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:* perl-win32-users-boun...@listserv.activestate.com [mailto: > perl-win32-users-boun...@listserv.activestate.com] *On Behalf Of *Chang > Min Jeon > *Sent:* Wednesday, May 13, 2009 5:44 AM > *To:* Perl-Win32-Users@listserv.ActiveState.com > *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.
_______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs