title: Bareword found where operator expected at Error in Perl script
body: <p>I have a script which is working fine in my local system (Cygwin in Windows 10).</p>
  <p>But when I run same in Linux machine x86_64 GNU/Linux this shows below error:</p>
  <pre><code>Bareword found where operator expected at script.pl line 22, near &quot;s/$regex/$1,/rg&quot;
  syntax error at script.pl line 22, near &quot;s/$regex/$1,/rg&quot;
  Execution of script.pl aborted due to compilation errors.
  </code></pre>
  <p>Here is my script:</p>
  <pre><code>#!/usr/bin/perl
  
  use strict;
  use warnings;
  use Data::Dumper;
  
  my $site_name    = $ARGV[0];
  my $type_of_site = $ARGV[1];
  
  chomp($site_name);
  chomp($type_of_site);
  
  my $var = `sh shell_script.sh $site_name $type_of_site`;
  #The above shell script gives me following data in $var
  #&quot;Result data [[The Incident result is shown with Node and IP address. error.log warning.log http://10.0.0.11/home/node_data/2020-07-08_data.txt NODE IP NODE1 10.0.0.1 NODE2 10.0.0.2 NODE3 10.0.0.3 NODE4 10.0.0.4 NODE5 10.0.0.5 ]]&quot;;
  
  print $var;
  
  my $regex = qr/.*?(?P&lt;Node&gt;\w+)\s(?:(?:\d{1,3}\.){3}\d{1,3}) ?]?]?/mp;
  
  my $result = $var =~ s/$regex/$1,/rg;
  
  chop $result;
  
  my @nodes_list = split /,/, $result;
  
  print Dumper(\@nodes_list);
  </code></pre>
  <p>I am extracting node names from the shell script resultant data using regex. But why its showing the error when I run it in Linux environment?</p>