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 6927605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:04:37+00:00 2026-05-27T11:04:37+00:00

We need to match certain data element by element that is an output in

  • 0

We need to match certain data element by element that is an output in tabular form obtained on the command prompt.The following is the approach being currently followed wherein the $Var contains the output. Is there an optimal way of doing this without directing the command output to file.

Please share your thoughts.

$Var = "iSCSI Storage     LHN StgMgmt Name  IP              Name
==============================================================
0                 Storage_1         15.178.209.194  admin
1                 acct-mgmt         15.178.209.194  storage1
2                 acct-mgmt2        15.178.209.194  storage2";

@tab = split("\n",$Var);
foreach (@tab) {
    next if ($_ !~ /^\d/);
    $_ =~ s/\s+//g;
    $first=0 if($_ =~ /Storage/i && /15.178.209.194/);
    push(@Array, $_); }
  • 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-27T11:04:38+00:00Added an answer on May 27, 2026 at 11:04 am

    $_ =~ /Storage/i && /15.178.209.194/ is silly. That gets broken up like this: ($_ =~ /Storage/i) && (/15.178.209.194/). Either use $_ consistently or don’t – the // and s/// operators automatically operate on $_.

    Also you should know that in the regex /15.178.209.194/, the .s are being interpreted as any character. Either escape them or use the index() function.

    Additionally, I would recommend that you separate each line using split(). This allows you to compare each individual column. You can use split() with a regex like so: @array = split(/\s+/, $string);.

    Finally, I’m not really sure what $first is for, but I notice that all three sample lines in that input trigger $first=0 as they all contain that IP and the string “storage”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to display certain data in a tabular form, and would prefer to
I need to get the products in the system that match certain criteria. How
I need to match something in the form <a href=pic/5 id=piclink><img src=thumb/5 /></a> to
i need to pull data out of an xml file based on certain field
I need to build a website where we display data that is refreshed every
I need to match a certain number of prefixes for a list of strings,
I need to be able to match a certain string ( '[' then any
I am working with 3 tables, trying to pull a list that match certain
In short, I need to match all URLs in a block of text that
I have a large amount of log data that I need to get some

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.