> Hi, I have a file like this: > > ......... > # PXE Class > vendor-class "PXEClient" { > default-lease-time 1800; > max-lease-time 1800; > option dhcp-class-identifier "PXEServer"; > > filename "/bootp/linux/3.0/alize/startup.txt"; > option vendor-encapsulated-options > "S G:/dhs3mgr/e15011.ae "; > } > > .......... > > and i would like to have this: > ........ > # PXE Class > vendor-class "PXEClient" { > default-lease-time 1800; > max-lease-time 1800; > option dhcp-class-identifier "PXEServer"; > > > } > .......
my $good_file = ''; while(<FILE>) { if(/^vendor-class/i){ $good_file .= $_; my $end_group = 0; while(<FILE>) { $good_file .= $_ unless $end_group; $end_group = 1 if /^\s*$/; last if /^\}/; } $good_file .= "}\n"; } } print $good_file; This loops over an open filehandle, starts a group for each line that starts with 'vendor-class', saves everything within vendor-class until the first blank line to $good_file, and breaks out of the inner while when it finds a '}' by itself on a line. Hope that helps, -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]