Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3981698
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:26:29+00:00 2026-05-20T05:26:29+00:00

I have a sub routine that creates an array of IP addresses, however I

  • 0

I have a sub routine that creates an array of IP addresses, however I do not know how many IPs will be pushed into the array. (based on how many matches in a txt file) Then I have another sub that needs to pull each IP address from the array and assign a variable. all IPs will be printed in the same line of output. I want to do something like this:

@IPS = ("1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4");  
print "vserver1 $IPS[0], vserver2 $IPS[1], vserver3 $IPS[2], vserver4 $IPS[3]\n";    

The problem is, I won’t know how many IPs will be in the array. How do I call an unknown number of values? Is it possible to assign a variable to the first IP, then the same variable assigned to the second IP the next time I call it?

print "vserver1 $IPS, vserver2 $IPS, vserver3 $IPS, vserver4 $IPS\n";  

thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:26:30+00:00Added an answer on May 20, 2026 at 5:26 am

    It is technically possible to do what you are asking, but it is not a good solution for this problem. Because even if a magic $IPS variable would walk along the array with each access, you would still not have the vserver# portion of your output.

    Instead, why not write a loop to process the array:

    print join(', ' => map {"vserver$_ $IPS[$_ - 1]"} 1 .. @IPS ), "\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a site that dynamically creates sub domain addresses for customers when
We have a sub-project 'commonUtils' that has many generic code-snippets used across the parent
I have a sub query that returns one column, showing as GroupType, I then
I have a sub form in Access: The CopyNo is a combobox that lets
I have an access form that creates a ppt file (set of slides) from
I am writing a high-score sub-routine for a text-based game. Here's what I have
I have a VB.net WPF application that creates a list from a databind. For
I have a Perl program that I've written that parses SQL-like statements and creates
Very simple problem: I have a Public Sub (in a module) that I want
I often have a subroutine in Perl that fills an array with some information.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.