Chas Owens wrote:

On 9/17/07, Jeff Pang <[EMAIL PROTECTED]> wrote:

2007/9/17, W. Sp. <[EMAIL PROTECTED]>:

Also, while using LWP modules, what type of
data is $content = get($url)? Is it an array? Is there a way to find out
what kind of data a particular variable stores?

It's a scalar.
you can use 'ref' to find out the variable type,like,

$ perl -MLWP::Simple -e '$c=get "http://www.aol.com/";print ref \$c'
SCALAR

You should probable not call ref in this way.  If $c had held a
reference to an array it would have printed REF instead of ARRAY.  Non
reference values return undef when passed to ref.  If you see SCALAR
that means the value is a reference to a scalar.  If you really want
to see output you should say something like this:

perl -MLWP::Simple -le '$c = get "http://3.am";print ref $c ? ref $c :
"SCALAR VALUE"'

Jeff's original post is very misleading. The use of LWP is ineffectual and
his code shows nothing about the contents of the scalar variable, only the
fact that it is, indeed, a scalar. It is equivalent to:

$ perl -e 'print ref \$c'

which also prints 'SCALAR'. Hooray!

Rob

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


Reply via email to