title: ERR Error compiling script (new function): user_script:2: '=' expected near 'end' , .../lib/site_perl/5.8.7/Redis.pm line 163
body: <p>I have created basic lua script to except a argument and print its value, using redis-cli its executing with no error and o/p is printed in log file.</p>
  
  <pre><code>$ cat test.lua
   redis.replicate_commands()
   local var = ARGV[1]
   print ( 'var ', var)
  $ redis-cli --eval test.lua , A
   nil 
  $
  </code></pre>
  
  <p>I want to run lua script using perl script : </p>
  
  <pre><code>$ cat eval.pl
  #!/usr/bin/perl
  
  use strict;
  use warnings;
  use Redis;
  
  my $r = Redis-&gt;new(
      server    =&gt; '127.0.0.1:6379',
      reconnect =&gt; 3,
      every     =&gt; 1.5 * 1000000,
      conservative_reconnect =&gt; 1,
      no_auto_connect_on_new =&gt; 1,
      cnx_timeout            =&gt; 15,
  );
  eval {
      $r-&gt;connect;
  };
  if ($@) {
      print '$@ : '.$@;
  }
  my $result = $r-&gt;eval( "test.lua", 0, 'A' );
  print "result : $result\n";
  $
  </code></pre>
  
  <p>But i am getting error: </p>
  
  <p><strong>[eval] ERR Error compiling script (new function): user_script:2: '=' expected near 'end' ,  at /../lib/site_perl/5.8.7/Redis.pm line 163</strong></p>
  
  <p>my redis version is 1.991</p>
  
  <p>error message is not descriptive enough to debug </p>
  
  <p>Redis.pm's code at line 163 is </p>
  
  <pre><code> 141 sub __with_reconnect {
   142   my ($self, $cb) = @_;
   143 
   144   ## Fast path, no reconnect
   145   $self-&gt;{reconnect}
   146     or return $cb-&gt;();
   147 
   148   return &amp;try(
   149     $cb,
   150     catch {
   151       ref($_) eq 'Redis::X::Reconnect'
   152         or die $_;
   153 
   154       $self-&gt;{__inside_transaction} || $self-&gt;{__inside_watch}
   155         and croak("reconnect disabled inside transaction or watch");
   156 
   157       scalar @{$self-&gt;{queue} || []} &amp;&amp; $self-&gt;{conservative_reconnect}
   158         and croak("reconnect disabled while responses are pending and conservative reconnect mode enabled");
   159 
   160       $self-&gt;connect;
   161       $cb-&gt;();
   162     }
   163   );
   164 }
  </code></pre>
  
  <p>Am i using sub eval wrong way ?</p>