what's wrong with @$ip?

?

****

use NetAddr::IP;
my $ip = new NetAddr::IP('10.0.0.0/30');
print join(' ', @$ip), "\n";

prints: Not an ARRAY reference
 
P

Paul Lalli

**** said:
use NetAddr::IP;
my $ip = new NetAddr::IP('10.0.0.0/30');
print join(' ', @$ip), "\n";

prints: Not an ARRAY reference

What are you asking? Your subject says "what's wrong with @$ip?", and
Perl is telling you exactly what's wrong with it - $ip is not an array
reference. You can therefore not dereference it as an array. $ip is an
object of type NetAddr::IP.

Perhaps you should try telling us what you're *trying* to do.

Paul Lalli
 
P

Paul Lalli

Paul said:
What are you asking? Your subject says "what's wrong with @$ip?", and
Perl is telling you exactly what's wrong with it - $ip is not an array
reference. You can therefore not dereference it as an array. $ip is an
object of type NetAddr::IP.

Perhaps you should try telling us what you're *trying* to do.

Okay, so I should really learn to read the docs of a module with which I
am unfamiliar before making a post like that. It seems the NetAddr::IP
class does support dereferencing its objects as arrays. I apologize for
my comments.

Given that, I would presume that the constructor did not return a valid
object. You can test that by inserting these lines:

use Data::Dumper;
print Dumper($ip);

If that does show that $ip is an object of NetAddr::IP, then perhaps you
are using a previous version of the module, which does not support the
dereferencing. Try printing $NetAddr::IP::VERSION. The latest on CPAN
is 3.20.

Excuse me while I now try to extract my foot from my mouth.
Paul Lalli
 
C

chris-usenet

Someone said:
use NetAddr::IP;
my $ip = new NetAddr::IP('10.0.0.0/30');
print join(' ', @$ip), "\n";

prints: Not an ARRAY reference

Paul Lalli said:
Perhaps you should try telling us what you're *trying* to do.

Seems to me that the OP is trying to repeat a variation of what's shown in
the documentation for NetAddr::IP. However, I can't see why it should fail
when that same snippet of code works for me (perl 5.6.1 on i386-linux;
perldoc NetAddr::IP shows "$Id: IP.pm,v 1.22 2004/03/02 20:23:57 lem
Exp $").

Chris
 
P

Peter Scott

Seems to me that the OP is trying to repeat a variation of what's shown in
the documentation for NetAddr::IP. However, I can't see why it should fail
when that same snippet of code works for me (perl 5.6.1 on i386-linux;
perldoc NetAddr::IP shows "$Id: IP.pm,v 1.22 2004/03/02 20:23:57 lem
Exp $").

Perhaps the OP is using Perl 5.005 or earlier, when overload.pm did not support
overloading dereferencing. That would produce this error, since the
NetAddr::IP object is in fact a hashref and it is only the overloading of
"@{}" that provides the semantics in question.
 
P

Peter Scott

Perhaps the OP is using Perl 5.005 or earlier, when overload.pm did not support
overloading dereferencing. That would produce this error, since the
NetAddr::IP object is in fact a hashref and it is only the overloading of
"@{}" that provides the semantics in question.

Nope, the two versions of NetAddr::IP on CPAN date back ~ 1 year and both
include "require 5.6.0". So unless we have a 5.6.0+ perl with an older
overload.pm, that theory's out.
 
?

****

**** said:
use NetAddr::IP;
my $ip = new NetAddr::IP('10.0.0.0/30');
print join(' ', @$ip), "\n";

prints: Not an ARRAY reference

problem is perl version (5.005)
thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top