On 9/17/07, Rob Dixon <[EMAIL PROTECTED]> wrote: > 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!
It isn't completely ineffectual, just misleading. If LWP::Simple::get had returned an arrayref then it would have said printed REF instead of SCALAR: perl -le '$c=[];print ref \$c' REF The problem is that it says the same thing for a hashref: perl -le '$c={};print ref \$c' REF or even a scalarref perl -le '$c=\$c;print ref \$c' REF -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/