Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Parsing a Hash

by northwestdev (Acolyte)
on Jul 21, 2009 at 22:33 UTC ( #782111=note: print w/replies, xml ) Need Help??


in reply to Re: Parsing a Hash
in thread Parsing a Hash

I am not seeing any warnings at all. I get a blank page (except when I dump the hash, which I posted in another message on this thread, and that's the real dump of the hash, with no warnings). Here's the entire code:
#!/usr/bin/perl use strict; use warnings; use Time::Local; use XML::DOM; use Net::Twitter; use Data::Dumper; use CGI; my $query = new CGI; print STDOUT $query->header; my $usename="myname"; my $pwd="mypwd"; my $twitterID="myname"; my $nt = Net::Twitter->new( traits => [qw/API::REST/], username => $usename, password => $pwd ); my $results = $nt->show_user($twitterID); #print Dumper $results; foreach my $user (@{ $results }) { my $id = $user->{id}; my $name = $user->{name}; print STDOUT $id." ".$name."<br>"; } print STDOUT $query->end_html;

Replies are listed 'Best First'.
Re^3: Parsing a Hash
by davorg (Chancellor) on Jul 22, 2009 at 08:05 UTC

    Well, I explained in the other thread what the problem is. The example code treats $results as an array ref but the show_user method returns a hash ref. You should get the (to my mind, really very clear) warning "Not an ARRAY reference".

    Which leaves us wondering why you're not seeing this warning when you clearly have use warnings in your code. My suspicion is that you're looking in the wrong place. All of the CGI scaffolding in your code makes me think that you're running this as a CGI program. Depending on which web server you're using and how it is configured several things can happen to warnings from CGI programs. The most common effect is that they are written to the web server error log. Did you look in there?

    You can force warnings and errors to be written to the browser by adding the following line to your code:

    use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

    But remember to remove it again before putting the program into production.

    It's also worth pointing out that just because your code is a CGI program, there's no reason why you shouldn't run it from your command line in order to try it out. I never put a CGI program onto a web server without running it from the command line first.

    --

    See the Copyright notice on my home node.

    Perl training courses

      Thank you. Your post in the other thread, came a couple of hours after I started this one. I am running it as a CGI program. I have no access to the server error logs, so I will try forcing the fatal erros using CGI::Carp
        I have no access to the server error logs

        If people expect you to do serious development, then they need to give you a sensible development environment.

        Why not set up a web server on your local machine?

        I will try forcing the fatal erros using CGI::Carp

        It's not fatal errors we're talking about. It's warnings.

        --

        See the Copyright notice on my home node.

        Perl training courses

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://782111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2022-08-15 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?