comparison usr/src/cmd/bsmrecord/filter_txt.pl @ 0:c9caec207d52 b86

Initial porting based on b86
author Koji Uno <koji.uno@sun.com>
date Tue, 02 Jun 2009 18:56:50 +0900
parents
children 1a15d5aaf794
comparison
equal deleted inserted replaced
-1:000000000000 0:c9caec207d52
1 #!/usr/perl5/bin/perl -w
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
9 #
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
14 #
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
20 #
21 # CDDL HEADER END
22 #
23 #
24 # Copyright (c) 2001 by Sun Microsystems, Inc.
25 # All rights reserved.
26 #
27 # ident "@(#)filter_txt.pl 1.2 05/06/08 SMI"
28
29 # local script to process audit_record_attr.txt -> audit_record_attr
30 #
31 # comments in the source file may start with "#" or "##" in any
32 # column. Those with double hash are retained as comments (but with a
33 # single "#") in the destination and the others are removed. Because
34 # of the comment removal, any sequence of more than one line of blank
35 # lines is also removed.
36
37 use strict;
38 require 5.005;
39
40 my $blankCount = 1; # not zero is a kludge to avoid making the first
41 # line of the output a blank line.
42 while (<>) {
43 s/(?<!#)#(?!#).*//;
44 if (/^\s*$/) {
45 $blankCount++ ;
46 next if ($blankCount > 1);
47 } else {
48 $blankCount = 0;
49 }
50 s/##/#/;
51 print;
52 }