Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Network Outlet

by Khen1950fx (Canon)
on Apr 29, 2012 at 03:12 UTC ( #967890=note: print w/ replies, xml ) Need Help??


in reply to Network Outlet

I encountered problems with URI::Escape, so I reworked your script to make it a little simpler. I used LWP::UserAgent instead of LWP::Simple and used ":content_file => " to make a file.

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use URI::Escape; print "Enter an URL and Press Enter: \n"; my $url = <ARGV>; my $ua = LWP::UserAgent->new; my $response = $ua->get( $url, ':content_file' => '/root/Desktop/url.log', ); die "Couldn't get $url" unless defined $response; if ($response->is_success) { print $response->decoded_content; } else { die $response->status_line; } my $videoURL = uri_escape_utf8($url); my $new_videoURL = uri_unescape($videoURL); print $new_videoURL ;
This is only a skeleton, but I think that you could usefully build upon it.

Updated: Revised. Thanks to jwkrahn for catching the mistake.


Comment on Re: Network Outlet
Select or Download Code
Re^2: Network Outlet
by jwkrahn (Monsignor) on Apr 29, 2012 at 06:53 UTC
    my $url = <ARGV>;

    Why change STDIN to ARGV?    And either way you still have to chomp the value received.

    while ($new_videoURL) { chomp; print $new_videoURL ; }

    Does $new_videoURL assign a value to $_?    And if not then why are you chomping the $_ variable?    And if the value in $new_videoURL doesn't change inside the loop then why are you using a loop at all?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-08-22 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (153 votes), past polls