Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How to duplicate lines

by bichonfrise74 (Vicar)
on Mar 04, 2010 at 00:06 UTC ( #826580=note: print w/replies, xml ) Need Help??


in reply to How to duplicate lines

Something like this?
#!/usr/bin/perl use strict; while (my $line = <DATA>) { print $line; if ( $line =~ /\sip address/ ) { $line =~ s/(\d+.\d+.\d+.)252/${1}100/; print $line; } } __DATA__ ip vrf forwarding ABC:Defgh ip address 1.1.1.1 255.255.255.252 ip vrf forwarding ABD: Efghi ip address 2.2.2.2 255.255.255.252

Replies are listed 'Best First'.
Re^2: How to duplicate lines
by ddrew78 (Sexton) on Mar 05, 2010 at 13:13 UTC
    Great, thank you so much. That did the trick.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://826580]
help
Chatterbox?
[Discipulus]: echo 'a'\'' gives me the prompt and then go with error on ctrl-d
[Discipulus]: uch! worst than windows!
[marto]: It's not worse, just different. Different shells, different tools. Different ways
[choroba]: Perl to the rescue!
[choroba]: yes, it's documented in man bash. You need to echo 'Joe'\''s home'

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2017-11-24 10:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (346 votes). Check out past polls.

    Notices?