title: Using different types of variables for piped gnuplot script
body: <p>I am trying to pipe a gnuplot script in perl to get some plots. My <code>data.dat</code> looks like:</p>
  
  <pre><code>1       5       2
  2       3       9
  3       9       6
  4       -4      8
  5       -3      4
  6       11      2
  7       0       -3
  8       -8      -2
  9       1       0
  10      22      0
  </code></pre>
  
  <p>I tried this script:</p>
  
  <pre><code>#!/usr/bin/perl -w    
  use strict;
  
  my $type="png";
  
  open(my $GP,'| gnuplot');
  
  print {$GP} &lt;&lt; "__GNUPLOT__";
  
  set style data lines
  #set logscale y
  set terminal $type
  set output 'pic.$type'
  plot "data.dat" u 1:2, "" u 1:3
  
  __GNUPLOT__
  
  close $GP;
  </code></pre>
  
  <p>My aim is to plot the log scale. Because of the negative data, I wanted to use <code>plot "data.dat" u 1:(abs($2)), "" u 1:(abs($3))</code>. So I want to get access to my perl-script variables and the gnuplot variables <code>$2</code> <code>$3</code>. Not quoting the heredoc <code>__GNUPLOT__</code> isn't working for this. I found those posts which treat a similar topic:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/a/11228232/2622293">gnuplot wont read $ character</a> </li>
  <li><a href="https://stackoverflow.com/a/4938198/2622293">using variables inside bash heredoc</a></li>
  </ul>
  
  <p>I don't know if this issue is the same for bash. I wasn't trying it yet, but would be interested there too. I just want to learn more about the general problem with piping, quoting and different types of variables.</p>