in reply to perl one liner to replace matching string

qx("perl -p -i -e \"s/(\@Filetyp\\s*?:)/\\1$ext/\" /path/test.c")

It is extremely rare that you need to call another perl from inside a Perl script! I'm going to guess that you're doing it for the effect of the -i flag? You can get that feature from inside Perl using $^I:

{ # new scope for local local @ARGV = '/path/test.c'; local $^I = ""; # -i command line switch while (<>) { s/(\@Filetyp\s*?:)/$1 c/; print; } }

Update: qx// is often problematic anyway!