On Nov 16, 1:54 pm, [email protected] (Vincent Li) wrote:
> On Tue, Nov 16, 2010 at 1:11 PM, Shawn H Corey <[email protected]> wrote:
>
> > On 10-11-16 04:07 PM, Vincent Li wrote:
>
> >> My aim is to remove specific profile.*{} block from that file
>
> > Yes, but if the {} blocks are nestable, then you can't do it with regular
> > expressions alone.
>
> right, I only have one level nested {}, any tips? when file is slurped
> to file mode, the nested {} will look like 'profile foo  { foo  { foo} foo  
> }profile bar  { bar  { bar } bar  }profile goo { goo } ', I
>
> tried regex:
>
> {.*?(?:{.*?})?.*?}
>
> but it is not working.


If the file is strictly formatted and there's no interior
nesting, you could even avoid slurping. Example:

      perl -nle 'print unless /^vlan vlan10 {$/ .. /^}$/'
           infile  > file_with_no_vlan10

See: perldoc perlop (range operator  "flip-flop")

--
Charles DeRykus


--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to