Here is one approach. Used __DATA__ to hold data for testing. Use dchomp to remove end of line.
#!perl -w while(<DATA>) { chomp; next if ( /^\s*$/ ); # if blank line bypass if ( /^B/ ) { $b = $_; chomp($c = <DATA>); if ( $c !~ /^C/ ) { printf "Expecting pairs of B,C. Received C, but got the foloowing for\n"; printf "the second record: <$c>\n"; die "Correct and rerun"; } }else { printf "Expecting pairs of B,C , but got the foloowing for\n"; printf "the first record: <$c>\n"; die "Correct and rerun"; } $b =~ s/B //; $c =~ s/C //; if ($b eq $c) { print "B $b\n"; } elsif ($b ne $c) { print "B $b\n"; print "C $c\n"; } } __DATA__ B water C water OUTPUT: B water Wags ;) -----Original Message----- From: M z [mailto:[EMAIL PROTECTED]] Sent: Monday, March 04, 2002 12:19 To: [EMAIL PROTECTED] Subject: urgent redundancy question Hi I'm trying to remove to analyze two successive lines in a row and remove one of them if they say the same thing, like so...based on different beginning charactes sample input: B water C water if so, then only keep B water and discard C water I tried doing so with this snippet, but it wasn't exactly working as scheduled I thought I would force analysis after the one time through the while, before the variables were changed in the second iteration of the while, but this was printing them way too many times!!! can someone please help an otherwise distressed individual. __________________________________________________ Do You Yahoo!? Yahoo! Sports - sign up for Fantasy Baseball http://sports.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]