Understanding Net::CIDR 0.09 output

Discussion in 'Perl Misc' started by Gerald Jones, Feb 4, 2004.

  1. Gerald Jones

    Gerald Jones Guest

    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.
    Gerald Jones, Feb 4, 2004
    #1
    1. Advertising

  2. Gunnar Hjalmarsson, Feb 4, 2004
    #2
    1. Advertising

  3. In article <bvpdjs$edu$>,
    Gerald Jones <> wrote:
    :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";
    --
    Strange but true: there are entire WWW pages devoted to listing
    programs designed to obfuscate HTML.
    Walter Roberson, Feb 4, 2004
    #3
  4. Gerald Jones

    Gerald Jones Guest

    In comp.lang.perl.misc Gunnar Hjalmarsson <> wrote:

    > Do not multi-post!


    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.
    Gerald Jones, Feb 4, 2004
    #4
  5. Gerald Jones <> wrote in news:bvpgsm$fe6$:

    > In comp.lang.perl.misc Gunnar Hjalmarsson <> wrote:
    >
    >> Do not multi-post!

    >
    > Have you ever heard of the Breidbart Index, Gunnar?
    >
    > <http://www.stopspam.org/usenet/mmf/breidbart.html>


    If you have a point, I do not get it. Clearly, BI ranks your multipost
    higher on the spam scale. That is, according to the criterion that you are
    using to counter Gunnar's objection to your spam, you are a spammer. So,
    why not apologize and stop doing that?

    Sinan.

    --
    A. Sinan Unur
    (reverse each component for email address)
    A. Sinan Unur, Feb 4, 2004
    #5
  6. Gerald Jones wrote:
    > In comp.lang.perl.misc Gunnar Hjalmarsson <>
    > wrote:
    >>
    >> Do not multi-post!

    >
    > 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.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Feb 4, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    3,388
    Andrew Thompson
    Jun 7, 2005
  2. =?iso-8859-15?q?Pekka_J=E4rvinen?=

    Calculating CIDR blocks

    =?iso-8859-15?q?Pekka_J=E4rvinen?=, Apr 20, 2007, in forum: Python
    Replies:
    5
    Views:
    502
    =?iso-8859-1?q?Pekka_J=E4rvinen?=
    Apr 20, 2007
  3. Jos Backus
    Replies:
    16
    Views:
    269
    Jos Backus
    Dec 2, 2006
  4. Antgoodlife

    Expand Shortended CIDR notation?

    Antgoodlife, Feb 9, 2009, in forum: Perl Misc
    Replies:
    2
    Views:
    307
    Antgoodlife
    Feb 9, 2009
  5. Ramesh
    Replies:
    7
    Views:
    136
    slebetman
    Apr 2, 2009
Loading...

Share This Page