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

Re^7: How to add a new line after three or four lines from a pattern after getting that pattern

by thanos1983 (Parson)
on Apr 03, 2019 at 13:23 UTC ( [id://1232093]=note: print w/replies, xml ) Need Help??


in reply to Re^6: How to add a new line after three or four lines from a pattern after getting that pattern
in thread How to add a new line after three or four lines from a pattern after getting that pattern

Hello again anirbanphys,

If you want to write the output to the file in one line you can do it like this:

io('out.txt')->appendln($_) for @lines; __END__ $ perl test.pl $ cat out.txt library(and_gate) { delay_model : table_lookup ; date : "Fri Mar 15 03:44:39 " ; time_unit : 1ms ; voltage_unit : 1V ; current_unit : 1A ; operating_conditions ("AB0.5v45c") { process : 1 ; temperature : 45 ; voltage : 0.5 ; } default_operating_conditions : "AB0.5v45c" input_voltage(default) { vi : 0 ; vh : 0.5 ; vim : 0 ; vin : 0.5 ; } }

You can use the method IO::All/appendln from the same package as you do for reading.

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!
  • Comment on Re^7: How to add a new line after three or four lines from a pattern after getting that pattern
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-26 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found