#! /usr/local/bin/perl -w # # TVM: read from stdin, output everything between $begin_pat and $end_pat # # Tim Mooney 12/17/98 use diagnostics; # use 5.004; open(IN,"to-vrml.tmp"); $begin_pat='vRmL'; $end_pat='vrML'; $in_pattern = 0; while () { if (/$begin_pat(..*?)$end_pat(.*)$/ && ($in_pattern == 0) ) { # # handle the case where the begin tag & the end tag are on the same line # print OUT "$1\n"; # now process anything after the $end_pat, so we handle multiple # occurrences of the tags on one line. $_ = $2; redo; } elsif (/$begin_pat(.*)$/ && ($in_pattern == 0) ) { $in_pattern=1; print OUT "$1\n"; } elsif (/^(.*)$end_pat/ && ($in_pattern == 1) ) { $in_pattern=0; print OUT"$1\n"; } elsif ( $in_pattern == 1 ) { # # print the entire line # print OUT"$_\n"; } } close(IN); open(INPUT,"to-vrml.tmp"); $begin_pat1='VRML'; $end_pat1='vrml'; $in_pattern = 0; while () { if (/$begin_pat1(..*?)$end_pat1(.*)$/ && ($in_pattern == 0) ) { # # handle the case where the begin tag & the end tag are on the same line # print OUT"$1\n"; # now process anything after the $end_pat, so we handle multiple # occurrences of the tags on one line. $_ = $2; redo; } elsif (/$begin_pat1(.*)$/ && ($in_pattern == 0) ) { $in_pattern=1; print OUT"$1\n"; } elsif (/^(.*)$end_pat1/ && ($in_pattern == 1) ) { $in_pattern=0; print OUT"$1\n"; } elsif ( $in_pattern == 1 ) { # # print the entire line # print OUT"$_\n"; } } close(INPUT); close(OUT);