title: Perl parameters passing with special characters
body: <p>This is a pure Perl parameters passing issue. I cannot use <code>Get::Opt</code> as it is not installed on every machine.</p>
  
  <p>I need to pass parameters with spaces and other special chars sometimes. Three scripts to demo the process. Is there a better way to do this?</p>
  
  <pre><code>[gliang@www stackoverflow]$ perl parameter_wrapper.pl
  prep.pl #&lt;5&gt; parameters
  prep_v2.pl #&lt;5&gt; parameters
  &lt;aaa_777-1&gt;
  &lt;bbb-6666-2&gt;
  &lt;Incomplete QA&gt;
  &lt;-reason&gt;
  &lt;too long, mail me at ben@example.com :)&gt;
  </code></pre>
  
  <hr/>
  
  <pre><code>cat parameter_wrapper.pl
  
  #!/usr/bin/perl -w
  use strict;
  # call prep.pl with 5 parameters
  my $cmd = "./prep.pl aaa_777-1 bbb-6666-2 'Incomplete QA' -reason 'too long,  mail me at ben\@example.com :)\n'";
  system($cmd);
  
  
  cat prep.pl
  
  #!/usr/bin/perl -w
  use strict;
  my @parameters = @ARGV;
  my $count = scalar(@parameters);
  
  my @parameters_new = wrap_parameters(@parameters);
  my $cmd = "./prep_v2.pl @parameters_new";
  print "prep.pl #&lt;$count&gt; parameters\n";
  system($cmd);
  
  sub wrap_parameters {
      my @parameters = @_;
      my @parameters_new;
      foreach my $var(@parameters) {
          $var = quotemeta($var);
          push(@parameters_new, $var);
      }
      return @parameters_new;
  }
  
  
  cat prep_v2.pl
  
  #!/usr/bin/perl -w
  use strict;
  my @parameters = @ARGV;
  my $count = scalar(@parameters);
  print "prep_v2.pl #&lt;$count&gt; parameters\n";
  
  foreach my $var (@parameters) {
      #print "&lt;$var&gt;\n";
  }
  </code></pre>