in reply to How to write the following code with comamnd line arguments using perl?

What version of Perl are you running? See the output of perl -v.

Although I can't reproduce the errors because I don't have an older version of Perl handy at the moment, based on the error messages I suspect it might be the s///r construct, which was added in Perl v5.14.

Try changing

my $base_name = $name =~ s/\.config$//r

to

(my $base_name = $name) =~ s/\.config$//