title: Querying cursor position with ANSI escape codes
body: <p>How can I use ANSI escape codes from within perl to query the cursor position?</p>
  
  <p>I'm trying </p>
  
  <pre><code>use strict;
  
  my $variable;
  
  open GRABSTDOUT, '&gt;', \$variable or die "Can't open STDOUT: $!";
  select GRABSTDOUT;
  
  print "\e[6n";
  select STDOUT;
  
  print "Cursor location is &gt;$variable&lt;\n";
  print "Bye\n";
  </code></pre>
  
  <p>But the query result is not being caught by my variable</p>
  
  <pre><code>mymachine:~/play&gt; perl ansi.pl
  Cursor location is &gt;&lt;
  Bye
  ^[[36;21Rmymachine:~/play&gt; ;21R
  </code></pre>