TechUser245 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to learn PERL. I want to use this function/module in PERL. I am not quite sure how to install / enable it.

output of perl -v ::--

This is perl 5, version 12, subversion 3 (v5.12.3) built for MSWin32-x86-multi-t hread Copyright 1987-2010, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.

My Script test1.pl::--

use strict; use warnings; use Net::Netmask; $block = Net::Netmask->new('192.168.1.128/25'); print "Base address: ", $block->base(), "\n"; print "Broadcast address: ", $block->broadcast(), "\n"; print "Net mask: ", $block->mask(), "\n"; print "Host mask: ", $block->hostmask(), "\n"; print "Bits: ", $block->bits(), "\n"; print "Size: ", $block->size(), "\n"; print "2:nd element: ", $block->nth(2), "\n";

When i run it, i am getting the following output ::--

Global symbol "$block" requires explicit package name at test1.pl line 5.

Global symbol "$block" requires explicit package name at test1.pl line 6.

Global symbol "$block" requires explicit package name at test1.pl line 7.

Global symbol "$block" requires explicit package name at test1.pl line 8.

Global symbol "$block" requires explicit package name at test1.pl line 9.

Global symbol "$block" requires explicit package name at test1.pl line 10.

Global symbol "$block" requires explicit package name at test1.pl line 11.

Global symbol "$block" requires explicit package name at test1.pl line 12.

Execution of test1.pl aborted due to compilation errors.

Any idea how to fix it ??

Replies are listed 'Best First'.
Re: net::netmask issue in Strawberry PERL
by Anonymous Monk on Sep 10, 2011 at 13:47 UTC
      Thanks a lot for your reply. I quickly scanned for my error and has fixed it. Will give some complicated stuff to my self to try and will see how i go. Thanks again.
Re: net::netmask issue in Strawberry PERL
by CountZero (Bishop) on Sep 10, 2011 at 22:11 UTC
    It is "Perl" (the language) or "perl" (the executable program that runs your scripts), but never ever "PERL".

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      Being a system admin, I am trying to learn this language to see where I can use it.

      Now, i thought lets try to find out the IP address of a computer using this script and try to change it later on. I was able to figure out the script to find the IP address.

      Is there a way I can ping that IP and if packets received is more than or eq 1, I can increase the IP by 1, do the same process and once i get the correct IP , change it using a script ?? I am using the following code now ::--

      use strict; use warnings; use diagnostics; use Net::Netmask; my $result = `ipconfig | find "IPv4 Address"`; ($result) = $result =~ m/(\d+\.\d+\.\d+\.\d+)/; print "OLD IP: $result\n";
      and getting following expected result ::-- OLD IP: 10.0.0.11
        Your script does not work on my version of Windows XP, so I cannot help you here.

        Perl is a great language for automating sys-admin tasks.

        Have a look at the Automating System Administration with Perl book (aka "The Otter Book") website.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James