Understanding Net::CIDR 0.09 output

G

Gerald Jones

Hi,

So this output might be shorthand for something but, I'm a newjack at
networking and I'd like to know if this is a bug (doubtful) or not. I have the
following snippet:

--8<--
#!/usr/bin/perl
use Net::CIDR; # using version 0.09

$cidr = Net::CIDR::range2cidr("1.2.3.0 - 1.2.3.255");
print "$cidr\n"; # outputs: 1.2.3.0/24

$cidr = Net::CIDR::range2cidr("1.2.3.4 - 1.2.3.255");
print "$cidr\n"; # outputs: 6

$cidr = Net::CIDR::range2cidr("1.2.3.4 - 1.5.6.7");
print "$cidr\n"; # outputs: 17
-->8--

So, what does the second two outputs mean? How do I convert it to the form of
the first output line?

Thanks,
Gerald.
 
W

Walter Roberson

:So this output might be shorthand for something but, I'm a newjack at
:networking and I'd like to know if this is a bug (doubtful) or not. I have the
:following snippet:

:$cidr = Net::CIDR::range2cidr("1.2.3.0 - 1.2.3.255");
:print "$cidr\n"; # outputs: 1.2.3.0/24

OK.


:$cidr = Net::CIDR::range2cidr("1.2.3.4 - 1.2.3.255");
:print "$cidr\n"; # outputs: 6

Net::CIDR::range2cidr probably wanted to return a list of 6 elements,
but you wanted the result put into a scalar, so perl automagically did
scalar() on the result. scalar() applied to a list returns the number
of elements in the list.


:$cidr = Net::CIDR::range2cidr("1.2.3.4 - 1.5.6.7");
:print "$cidr\n"; # outputs: 17

Same thing.

Try

@cidr = Net::CIDR::range2cidr("1.2.3.4 - 1.5.6.7");
print "@cidr\n";
 
G

Gunnar Hjalmarsson

Gerald said:
Have you ever heard of the Breidbart Index, Gunnar?

<http://www.stopspam.org/usenet/mmf/breidbart.html>

and, Proverbs 17:28?

Even a fool, when he holdeth his peace, is counted wise: and he
that shutteth his lips is esteemed a man of understanding.

No, I hadn't heard of either.

But I try to apply common sense when posting to newsgroups, and
posting multiple copies of the same help request to different
newsgroups is simply rude. Why? Because it might lead to somebody
making efforts to help you without knowing that you already got the
help you need somewhere else.

Cross-posting, on the other hand, may occationally be motivated.

You may think it's foolish to react when somebody multi-posts. Well, I
disagree, and I'll keep reacting to that rude behaviour. Would guess
that most people who use Usenet regularly would agree with me.
 

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,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top