CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Perl one liner inside system command


New User

Jan 19, 2016, 2:09 AM

Post #1 of 2 (2365 views)
Perl one liner inside system command Can't Post


I'm trying to call perl one liner inside system command but it fails.

system ("cat /svn/csvn/data/repositories/$crepo/conf/svnperms.conf |/usr/bin/perl -ane 'if(/$Release =.*/) {$_=~s/$email//g;print}else{print}' >>$");

cat file and remove one word that matches a pattern
for example :-

file.txt which has
JOHN = one two three

in one liner im able to remove the word "two" using the below

cat file.txt | perl -ane 'if(/JOHN.*=.*/) {$_=~s/two//g;print}else{print}'

but the same fails when i call it in a system command inside my script.

Any help Appreciated.

Veteran / Moderator

Jan 19, 2016, 7:22 AM

Post #2 of 2 (2345 views)
Re: [john_oracle] Perl one liner inside system command [In reply to] Can't Post

Why are you doing this as a piped system command without any error checking/handling?

This is perl, not shell scripting.

Instead of the system call, open the file in the script and process it as needed. I also recommend that you take a look at some of the config parser modules on cpan to find one that can aide in modifying the file.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives