in reply to Re^2: regex help!
in thread regex help!
#!C:/Perl/bin use strict; # no warnings because using uninit values below use Data::Dumper::Simple; use vars qw ( @nomatch $I1 $I2 $I3 $L1 $L2 @data $i $j ); while (<DATA>) { push @data,$_ ; } { while (@data) { $L2 = pop @data; chomp $L2; #print "\$L2 is: $L2\n"; $L1 = pop @data; chomp $L1; #print "\$L1 is: $L1\n"; #find the data here if ( $L1 =~ / \d\d\d # three digits \s+ # one or more whitespace NP # exact string, NP \s+ # one or more whitespace U # exact string, U \s+ # one or more whitespace Pu # exact string, Pu /x # end match, extended && $L2 =~ / (\d\d\d) # three digits \s+ # one or more whitespace (\d\.\d{6}) # digit, period, six digits \s+ # one or more whitespace (\d{6}) # six digits \s+ # one or more whitespace (\d\.\d{6}) # digit, period, six digits /x ) { my $n1 = $1; $I1 = $2; $I2=$3; $I3=$4; print "\n\tIn linepair ENDING with $n1, NP: $I1, U: $I2, Pu: + $I3\n"; } else { push @nomatch,"\n\tNo match on lines $L1\n\t\t\t and $L2\ +n"; } } print "\n\n\t No Match pairs follow\n"; warn Dumper (@nomatch); } __DATA__ 000 NP U Pu 001 1.270000 000001 3.141000 002 Lev N Pu 003 0.13 000001 3.277118 004 NP U Pu 005 1.000220 000002 3.098761 006 Yac S Yb 007 10.33000 000001 90000000 008 NP U Pu 009 2.130000 000140 5.797712
|
|---|