I have a file that looks like this:
strategies{ XLON_DBX0F2_GBP DynamicSpreadQuoter { tradingServiceAttributes { session LSE1 } fairPrice { securityID LU0490618542 securityIDSource 4 service IDNPS } } XLON_DBX1AE_GBP DynamicSpreadQuoter { tradingServiceAttributes { session LSE3 } fairPrice { securityID LU0322252127 securityIDSource 4 service NMP_ABPS } } XLON_DBX1AE_USD DynamicSpreadQuoter { tradingServiceAttributes { session LSE1 } fairPrice { securityID LU0322252171 securityIDSource 4 service NMP_ABPS } } ;; }
What I want is to pass multiple strings to my script (for example 'XLON_DBX1AE_USD','XLON_DBX1AE_GBP',..) The script should then delete everything starting from there until the last closed bracket "}" for this particular block. Currently my script works if I pass ONE string to it but I just don't know how to modify it if I want to pass more than one string. Can anyone please help me on this? Appreciate your help in advance.
My code:
#!/usr/bin/perl # use strict; use warnings; # my $match='XLON_DBX1AE_USD'; my $file = $ARGV[0]; # open (my $fh, '+<', $file) or die "Could not open \"$file\"$!\n"; # my $depth = 0; while(<$fh>) { if($_=~ /$match/){ $depth = /\}/ ? 0 : 1; while($depth) { $_=<$fh>; $depth-- if /}/; $depth++ if /{/; } } else { print; } }
In reply to delete multiple string blocks by grandagent
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |