in reply to How to parse a text file
#!/usr/bin/perl use strict; local $/ = '}'; while( <DATA> ) { if ( /\s+service_description\s+/ ) { next; } else { s/(use\s+)sam(\w+)/$1$2/; } print; } __DATA__ define service{ use sam_win_cpu_load host_name buo.va.com contact_groups buo_admins } define service{ use generic-service host_name buo.va.com service_description MS SQL Server check_command check_service_state!MSSQLSERVE +R!public contact_groups buo_admins }
|
|---|