title: How can I list all variables that are in a given scope?
body: <p>I know I can list all of the package and lexcial variables in a given scope using <a href="http://search.cpan.org/dist/PadWalker/PadWalker.pm" rel="noreferrer"><code>Padwalker</code></a>'s <code>peek_our</code> and <code>peek_my</code>, but how can I get the names and values of all of the global variables like <code>$"</code> and <code>$/</code>?</p>
  
  <pre><code>#!/usr/bin/perl
  
  use strict;
  use warnings;
  
  use PadWalker qw/peek_our peek_my/;
  use Data::Dumper;
  
  our $foo = 1;
  our $bar = 2;
  
  {
      my $foo = 3;
      print Dumper in_scope_variables();
  }
  
  print Dumper in_scope_variables();
  
  sub in_scope_variables {
      my %in_scope = %{peek_our(1)};
      my $lexical  = peek_my(1);
      #lexicals hide package variables
      while (my ($var, $ref) = each %$lexical) {
          $in_scope{$var} = $ref;
      }
      ##############################################
      #FIXME: need to add globals to %in_scope here#
      ##############################################
      return \%in_scope;
  }
  </code></pre>