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

Hello finddata,

I execute your code and I get:

$ perl test.pl Could not open file 'sample.txt': No such file or directory at test_2. +pl line 74.

We need sample of your file.

Update: I think your mistake is extra backslash forward slash "/"on your regex.

Something like that:

s/\.config$/r

Similar question: (perl s/this/that/r ==> “Bareword found where operator expected”)

Update2: Copied from the question above:

As ruakh wrote, /r is new in perl 5.14. However you can do this in previous versions of perl:

(my $foo = $bar) =~ s/this/that/;

Update3: As haukex suggested I think the Perl Version that you are running is the problem.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: The following error occurs for below code.Help me to solve this?
by Anonymous Monk on Mar 13, 2017 at 12:27 UTC
    backslash "/"

    That's a forward slash.

      Hello Anonymous Monk,

      You are right, I just updated.

      Thanks for noticing.

      Seeking for Perl wisdom...on the process of learning...not there...yet!