CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Padre Perl printing/software problem

 



mk_bold
Novice

Feb 13, 2014, 4:42 AM

Post #1 of 3 (990 views)
Padre Perl printing/software problem Can't Post

This is not as much a perl question as a Padre question. So I am not sure I put it the correct place.

I am working on a Oauth script in Padre perl (1.00) and having trouble printing the output out to see if it works.

This do not give any output:

Code
# Get tokens 
my $tokenString = get_token();
# Split get_token response into a hash.
my %words = split /[=&]/, $tokenString;
# Define the tokens:
my $oauth_token = $words{oauth_token};
my $oauth_token_secret = $words{oauth_token_secret};
# Test if it works
print "Oauth: $oauth_token\nOauth secret: $oauth_token_secret";


But if I take the exact same code, but add a few newlines before print. It works:

Code
# Get tokens 
my $tokenString = get_token();
# Split get_token response into a hash.
my %words = split /[=&]/, $tokenString;
# Define the tokens:
my $oauth_token = $words{oauth_token};
my $oauth_token_secret = $words{oauth_token_secret};
# Test if it works





print "Oauth: $oauth_token\nOauth secret: $oauth_token_secret";


Why on earth is that?! Is it just a very weird bug or am I missing something here?

The full code below (modified version of an example found online):

Code
#!/usr/bin/perl -w 
# Hattrick Oauth:
use strict;
use diagnostics;

use strict;
use lib 'extra_mods';
use lib 'extra_mods/5.8';
use JSON;
use Net::OAuth;
use LWP::UserAgent;
use Data::Dumper;

$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;

# PROVIDE YOUR KEY HERE
my $cc_key = "blalbalblablab";

# PROVIDE YOUR SECRET HERE
my $cc_secret = "lalalallalallaalallaa";

# Get tokens
my $tokenString = get_token();
# Split get_token response into a hash.
my %words = split /[=&]/, $tokenString;
# Define the tokens:
my $oauth_token = $words{oauth_token};
my $oauth_token_secret = $words{oauth_token_secret};
# Test if it works





print "Oauth: $oauth_token\nOauth secret: $oauth_token_secret";

# Get token sub:
sub get_token {
my $ua = LWP::UserAgent->new;

# Source Url
my $url = "https://chpp.hattrick.org/oauth/request_token.ashx";

# Create request
my $request = Net::OAuth->request("request token")->new(
consumer_key => $cc_key,
consumer_secret => $cc_secret,
request_url => $url,
request_method => 'GET',
signature_method => 'HMAC-SHA1',
timestamp => time,
nonce => 'hsu94j3884jdopsl',
callback => ' https://chpp.hattrick.org/oauth/request_token.ashx',
);

# Sign request
$request->sign;

# Get message to the Service Provider
my $res = $ua->get( $request->to_url );

# If request is success, display content
if ( $res->is_success ) {
return $res->content;
}
else {
# Print error and die
Dumper $res;
die "Something went wrong";
}
}



FishMonger
Veteran / Moderator

Feb 13, 2014, 6:19 AM

Post #2 of 3 (978 views)
Re: [mk_bold] Padre Perl printing/software problem [In reply to] Can't Post

This is a Padre issue. I've never used Padre so I can't say what's causing this or how to fix it.

You might want to post your question on a forum dedicated to Padre. Check out this: http://padre.perlide.org/contact.html


mk_bold
Novice

Feb 15, 2014, 4:30 AM

Post #3 of 3 (953 views)
Re: [FishMonger] Padre Perl printing/software problem [In reply to] Can't Post

thank you.

I'm trying to report the bug now.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives