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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.