Results 1 to 2 of 2

Thread: Getting a list of ipaddress from the array using perl

  1. #1
    Contributing Member
    Join Date
    Oct 2006
    Answers
    67

    Getting a list of ipaddress from the array using perl

    Hi,

    I want to display the ipaddress lists from the array using perl.
    The arrays can be like this : @list1 = (1..10) or @list2 = ('A'..'Z'). It can be printed as: list1 will be from 1 to 10 and list2 will be from A to Z.

    Like this, i want to print the set of ipaddress.
    The ipaddr array is: @ipaddr = ('192.168.30.1' .. '192.168.30.10').

    How to print the ipaddresses from 192.168.30.1 to 192.168.30.10?
    This is not the same approach followed in printing the numbers and chars. Regular expressions can be used. I tried my best. Anybody please help me.


  2. #2
    Expert Member
    Join Date
    Apr 2006
    Answers
    124

    Re: Getting a list of ipaddress from the array using perl

    Hi,

    check this
    @ipaddr = ("192.168.30.1","192.168.30.2","192.168.30.3","192.168.30.4","192.168.30.5","192.168.30.6","192.168.30.7","192.168.30.8","192.168.30.9","192.168.30.10");

    foreach my $key(@ipaddr) {
    print "the ipaddr is $key \n";
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact