Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Formatting an array

by AnomalousMonk (Chancellor)
on Feb 08, 2018 at 02:00 UTC ( #1208672=note: print w/replies, xml ) Need Help??


in reply to Formatting an array

Maybe something like:

c:\@Work\Perl\monks>perl -wMstrict -le "use Regexp::Common qw(net); ;; my @strings = ( '/data/alcatel_7750/routername1- static-route 1.1.1.1/30 next- +hop 2.2.2.2 tag 624', '/data/alcatel_7750/routername2- static-route 1.1.1.3/30 next- +hop 3.3.3.3 tag 624', '/data/alcatel_7750/routername3- static-route 1.1.1.2/30 next- +hop 4.4.4.4 tag 628', ); ;; my $rx_ipv4_dotted_dec = qr{ (?<! \d) $RE{net}{IPv4} (?! \d) }xms; my $rx_routename = qr{ \b [[:alpha:]] \w* \b }xms; my $rx_route = qr{ \b [[:alpha:]] [[:alpha:]-]* \b }xms; ;; for my $s (@strings) { my $parsed = my ($r_name, $r_ip) = $s =~ m{ / ($rx_routename) - \s+ ($rx_route \s+ $rx_ipv4_dotted_dec / \d+) }xms; ;; die qq{bad record: '$s'} unless $parsed; ;; print qq{'$s' -> \n ($r_name) ($r_ip)}; } " '/data/alcatel_7750/routername1- static-route 1.1.1.1/30 next-hop + 2.2.2.2 tag 624' -> (routername1) (static-route 1.1.1.1/30) '/data/alcatel_7750/routername2- static-route 1.1.1.3/30 next-hop + 3.3.3.3 tag 624' -> (routername2) (static-route 1.1.1.3/30) '/data/alcatel_7750/routername3- static-route 1.1.1.2/30 next-hop + 4.4.4.4 tag 628' -> (routername3) (static-route 1.1.1.2/30)


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1208672]
help
Chatterbox?
[usemodperl]: perl is not broken, perl is being broken by the web being broken by https, for the love of banking apps on free wifi at coffee shops or something...
[Veltro]: Wondering, would it be so hard to write a small application that you can access using http which forwards the request over web ussing ssl?
[Veltro]: are there not even tools for that?
[usemodperl]: the breakage is so fresh i guess not, so it's up to us! :-)
[usemodperl]: someone has yet to make that future famous free http to https proxy written in perl and supported by ads, paypal, patreon, etc to make millions of dollars a minute!
[Veltro]: Why would this be fresh, I recon this is stuff that happens all the time (not Perl per se)
[Corion]: usemodperl: I'm sure you could even code that on the command line.
[usemodperl]: definitely

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2018-06-24 17:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?