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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:50:30+00:00 2026-05-31T02:50:30+00:00

This is the configuration I have, and I’m trying to consolidate this into a

  • 0

This is the configuration I have, and I’m trying to consolidate this into a single route command that i could paste into a Cisco ASA.

set device "internal"
set dst 13.13.13.13 255.255.255.255
set gateway 172.16.1.1

set device "internal"
set dst 14.14.14.14 255.255.255.255
set gateway 172.16.1.1

set device "internal"
set dst 15.15.15.15 255.255.255.255
set gateway 172.16.1.1

Join it to a single device, then modify it accordingly to end up looking something like this

route internal 13.13.13.13 255.255.255.255 172.161.1.1

then the other 3 lines can go away.

I’d like to do this in Perl since i’m writing other scripts to do other portions of the source configuration

  • 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-31T02:50:32+00:00Added an answer on May 31, 2026 at 2:50 am

    Assuming that your order is always device,dst,gateway then this works:

    use strict;
    use warnings;
    
    
    my @devices=(); #Array to store device strings
    my $current_device=""; #String to capture current device.
    
    while(<DATA>)
    {
        chomp;
        if(/^set (\w+) (.+)$/)
        {
            if($1 eq "device")
            {
                $current_device="route $2";
                $current_device=~s/"//g;
            }
            elsif($1 eq "dst")
            {
                $current_device.=" $2";
            }
            elsif($1 eq "gateway")
            {
                $current_device.=" $2";
                push @devices,$current_device;
            }
        }
    }
    
    print "$_\n" foreach(@devices);
    
    
    
    
    __DATA__
    set device "internal"
    set dst 13.13.13.13 255.255.255.255
    set gateway 172.16.1.1
    
    set device "internal"
    set dst 14.14.14.14 255.255.255.255
    set gateway 172.16.1.1
    
    set device "internal"
    set dst 15.15.15.15 255.255.255.255
    set gateway 172.16.1.1
    

    The output is:

    route internal 13.13.13.13 255.255.255.255 172.16.1.1
    route internal 14.14.14.14 255.255.255.255 172.16.1.1
    route internal 15.15.15.15 255.255.255.255 172.16.1.1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying out GWT in this 'configuration': 1) I have written a server
I have been trying to run with JRebel this configuration: Here is my output:
I am trying to build a sample app using Monotouch. I have this configuration/setup
I have this configuration: A page containing a search field, at the submit in
I have this configuration of nginx : server { listen 80; server_name example.com www.example.com;
In my DefaultRegistry I have this configuration: ForRequestedType<INHUnitOfWork>().CacheBy(InstanceScope.HttpContext) .TheDefault.Is.OfConcreteType<NHibernateUnitOfWork>(); At some point in the
well i have a configuration like this in the components part of my config
I'm working in xmldataprovider and we have configuration value source this value may be
So I have this code inside my lib/ folder: class GlobalConfig::SetHelper def self.yes_no_input(configuration) value
I have this msbuild target in my csproj file: <Target Name=AfterBuild Condition= '$(Configuration)' ==

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.