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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:37:56+00:00 2026-06-01T17:37:56+00:00

I am trying to extract the Interface from an array created from an SNMP

  • 0

I am trying to extract the Interface from an array created from an SNMP Query.

I want to create an array like THIS:

my @array = ( "Gig 11/8",
              "Gig 10/1",
              "Gig 10/4",
              "Gig 10/2");

It currently looks like THIS:

my @array = 
( "orem-g13ap-01    Gig 11/8          166            T       AIR-LAP11 Gig 0",
  "orem-g15ap-06    Gig 10/1          127            T       AIR-LAP11 Gig 0",
  "orem-g15ap-05    Gig 10/4          168            T       AIR-LAP11 Gig 0",
  "orem-g13ap-03    Gig 10/2          132            T       AIR-LAP11 Gig 0");>

I am doing THIS:

foreach $ints (@array) {
         @gig = substr("$ints", 17, 9);
         print("Interface: @gig");

Sure it works, but the hostname [orem-g15ap-01] doesn’t always stay the same length, it varies depending on the site. I need to extract the word “Gig” plus the next 6 characters. I have no idea what is the best way of doing this.

I am a novice at perl but trying. Thanks

  • 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-06-01T17:37:57+00:00Added an answer on June 1, 2026 at 5:37 pm
    # "I need to extract the word "Gig" plus the next 6 characters."
    # This looks like a fixed-with file format, so consider using unpack.
    foreach ( @lines ) {
        my( $orem, $gig, $rest ) = unpack 'a17 a9 a*';
        print "[$gig]\n";
    }
    

    If it’s not fixed-with format, then you need to find out what the file spec is and then maybe use a regular expression, something like:

        my( $orem, $gig, $rest ) = m/(\S+)\s+(.{9})(.*)/;
    

    But this will not work in the general case without a proper file spec.

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

Sidebar

Related Questions

I am trying to use Delphi 2009's refactoring to extract an interface from a
I am trying to extract some info from a website using simple_html_dom. Currently I
hi i'm trying to extract values from this tagged file here is the file
im trying to extract the most common YEAR from an array of DateTime objects
Trying to extract strings that are wrapped in double brackets. For example [[this is
I'm trying to extract about 72000 SInt32s from the iPhone, but not sure what
I'm trying extract the nth + 1 and nth + 3 columns from a
I am trying to extract the number of specials unlocked at a venue from
This class property is what I'm trying to refactor into an interface. public class
Im trying to extract a line from wget's result but having trouble with it.

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.