On Fri, 2 Apr 2004 14:17:21 -0800 , Bajaria, Praful wrote:
> :) the below code works.... 
> my $content = $request->content;
> print "content: $content\n";
> 
> but this doesn't work print "content: ".$request->content."\n";
> 
> Anyways, why do u have to assign to a var and print ? 
Okay... the use of the $request hash variable was just an example. Yours should be 
$response->content, following your earlier example:

See the following example:

---example start---

#!/usr/local/bin/perl

use warnings;
use strict;

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
my $response = $ua->get( 'http://www.cnn.com/' );

if ( $response->is_success )
{
        print "Content:\n".$response->content."\n";
}
else
{
        print "Error:\n".$response->message."\n";
}

---example end---

You have to use the dot-concatenation or save the result of $module->function into a 
variable because it, in your case $response->content, isn't a variable. It is a 
function that returns a variable. Because of that perl just prints the memory address 
of the modules data structure in your memory if you try to let perl do the string 
substitution for you.

/oliver/

BTW.: You might also just try to enter

        perldoc perl

at your terminal prompt.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to