Next | Program Repair Shop | 69 |
Subject: pattern matching
Message-Id: <98rf06$dao$1@newsg2.svr.pol.co.uk>
...
elsif ((($_ =~ m/^P\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(
\d*|-\d*)/) or
($_ =~ m/^\s\s(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\d*|-\d*
);/) or
($_ =~ m/^\s\s(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)/) or
($_ =~ m/^\s\s(\S*)\s*(\S*)\s*(\S*)\s*(\S*);/) or
($_ =~ m/^\s\s(\S*)\s*(\S*;)/))
and (($flagds2 ==1) and ($tcell_type_flag eq Leaf)))
I'm not sure just what this code was supposed to be doing
(I don't think the original code was working correctly)
The data looked like this:
P 1234 4567 23 244 445 1236 1234 7890 1234 555 6 666 -450 -900 670 -30; P 1234 456 -700 -800 -76000 -600 -900 -785 1234 455; P 1234 4567 23 244 445 1236 1234 7890 1234 555 6 666 -450 -900 670 -30 45 44 3 -20;
Something like this was surely possible:
s/;\s*$//; my @numbers = split; if ($numbers[0] eq 'P') { $P_line = 1; shift @numbers } # Now do something with @numbers...
Next | Copyright © 2006 M. J. Dominus |