Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: How to repeat a string multiple times if found match

by BillKSmith (Monsignor)
on Mar 10, 2021 at 03:54 UTC ( [id://11129389]=note: print w/replies, xml ) Need Help??


in reply to How to repeat a string multiple times if found match

This one-liner even creates a back-up in case things go wrong!
>perl -pibak -e"$_ = qq(foo_1\nfoo_2\nfoo_3\nfoo_4\n) if /^foo_$/" xx. +txt >dir xx.txt* Volume in drive C is Windows Volume Serial Number is AE03-D45F Directory of C:\Users\Bill\forums\monks 03/09/2021 10:47 PM 57 xx.txt 03/09/2021 07:04 PM 35 xx.txtbak 2 File(s) 92 bytes 0 Dir(s) 379,932,401,664 bytes free >type xx.txt hello world foo_1 foo_2 foo_3 foo_4 foo abc
Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129389]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-26 09:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found