in reply to Remove multiple lines in file if pattern found based on array element, in perl

Understand your data. Something like this works.

use warnings; use strict; while(<DATA>){ print unless/^#+?\s.+vss #+?$/sm .. /\}/; } __DATA__ # Bind ::d::autoBindmap $intfcName -------------so many other lines------------------------------ ############ Power information for vss ##################### #---------------------------- #pg_vss s100 #---------------------------- #Add pg_vss_dl interface set intfcName pg_vss 1.0 s 100 #Add Verilog port binding for vss ::d::autoBindmap $module pg_vss $intfcName { VSSGND vss_dl; } ############ Power information for vdd ##################### #---------------------------- #pg_vdd s100 #---------------------------- #Add pg_vdd_dl interface set intfcName pg_vdd 1.0 s 100 #Add Verilog port binding for vss ::d::autoBindmap $module pg_vdd $intfcName { VDD vss_dl; } -----------------------so many other lines---------------------------- +--- #write component ::d::writeLib $module
You know one of the value you are looking for will be "vss", but since I know what your array holds. This could do.

  • Comment on Re: Remove multiple lines in file if pattern found based on array element, in perl
  • Download Code

Replies are listed 'Best First'.
Re^2: Remove multiple lines in file if pattern found based on array element, in perl
by MatD (Initiate) on Nov 07, 2014 at 00:15 UTC

    Thank you for reply. The problem here is that @remove_power_list keeps on changing, for each file. @remove_power_list is generated on the fly in bigger part of code. It may or may not have "vss" as one of its element.

    So, I cannot use any fixed string here. I have to iterate through @remove_power_list array.

    Hope this makes sense.