title: How to print out JSON object in perl using AnyEvent::Twitter::Stream
body: <p>I'm using the AnyEvent::Twitter::Stream module to grab tweets.  Ultimately I'm trying to print the tweets to a file but I'm unable (I think) to get the tweet as a JSON object.  My code is as follows:</p>
  
  <pre><code>#!/Applications/XAMPP/xamppfiles/bin/perl
  
  use AnyEvent::Twitter::Stream;
      my $done = AnyEvent-&gt;condvar;
  
  BEGIN {
      use Exporter;
      our @ISA = qw(Exporter);
      our @EXPORT = qw{
         &amp;init
      };
  }
  
  sub print_tweet {
    my $tweet = shift;
    print $tweet;   
  }
  
  
    # receive updates from @following_ids
    my $listener = AnyEvent::Twitter::Stream-&gt;new(
        username =&gt; XXXXXX
        password =&gt; XXXXXX
        method   =&gt; 'sample',  # "firehose" for everything, "sample" for sample timeline
        decode_json =&gt; 1,
        on_tweet =&gt; sub {
            my $tweet = shift;
            print_tweet($tweet);
        },
        on_keepalive =&gt; sub {
            warn "ping\n";
        },
        on_delete =&gt; sub {
            my ($tweet_id, $user_id) = @_; # callback executed when twitter send a delete notification
        },
        timeout =&gt; 45,
    );
  
  $done-&gt;recv;
  </code></pre>
  
  <p>Yet when I print out the tweet in the print_tweet subroutine all I get is:</p>
  
  <pre><code>HASH(0x8f0ad0)HASH(0x8f0640)HASH(0x875990)HASH(0x8f0ab0)HASH(0x8e0d80)HASH(0x8f06e0)HASH(0x8f08f0)HASH(0x93ef30)HASH(0x876190)HASH(0x93ee60)HASH(0x8f0610)HASH(0x8f0b00)HASH(0x8e13e0)HASH(0x93ee20)HASH(0x8f0a20)HASH(0x8e1970)HASH(0x8f0900)
  </code></pre>
  
  <p>I've even tried to print out the tweet assuming it is a hash as follows:</p>
  
  <pre><code>sub print_tweet {
    my ($jsonref, $tweet) = @_;
    my $tweet = shift;
    print %tweet;
  }
  </code></pre>
  
  <p>Yet that produced nothing.  It appears that AnyEvent::Twitter::Stream is returning $tweet as an object based on their sample code of:</p>
  
  <pre><code>  on_tweet =&gt; sub {
        my $tweet = shift;
        warn "$tweet-&gt;{user}{screen_name}: $tweet-&gt;{text}\n";
    },
  </code></pre>
  
  <p>And I know I can print out individual objects, but can I get teh raw JSON object?  I must be missing something or my 'noob'ness is greater than I thought...</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>I was able to ALMOST get it by changing print_tweet to the following:
  
  sub print_tweet {
    my $tweet = shift;
    my $json_output = to_json($tweet);
    print $json_output;
  }
  </code></pre>
  
  <p>It prints out MOST of the JSON object but complains about wide characters, which I believe is an issue with the output being utf8 format?  I'm unsure how to solve this issue though....</p>