sub Parse_SM_Sub_Header { # # [...private notes...] # # The array returned by this sub contains the following items: # # 0 Sub system # 1 Marriage state # 2 Marriage vote # 3 Split plan # 4 Split plan lock # 5 Link plan # 6 Link plan lock # 7 Split plan vote # 8 Link plan vote # 9 Cycle time lock # 10 Cycle time # 11 Rotation state # 12 Rotation amount # 13 Requested cycle time # 14 VF state # 15 Critical SA # 16 Critical SA DS # my ($line) = @_; my ($tmpbuf); my (@retarg); my %patterns = ( qr/SS\s*(\d+)([MF# ])([\+\- ])/ => sub { push(@retarg, $1); # Sub system push(@retarg, $2); # Marriage state push(@retarg, $3); # Marriage vote }, qr/PL\s*(\d+)([\#\.])(\d+)([\#\.]?)/ => sub { push(@retarg, $1); # Split plan $tmpbuf = $2; # Split plan lock $tmpbuf = "" if ($tmpbuf ne "#"); push(@retarg, $tmpbuf); push(@retarg, $3); # Link plan $tmpbuf = $4; # Link plan lock $tmpbuf = "" if ($tmpbuf ne "#"); push(@retarg, $tmpbuf); }, qr/PV\s*([a-z]?\d+)(\.)(\d+)/ => sub { push(@retarg, $1); # Split plan vote push(@retarg, $3); # Link plan vote }, qr/C[LT]\s*([\#\^]?)\s*(\d+)\s*([\+\-])(\d+)\s*/, => sub { push(@retarg, $1); # Cycle time lock push(@retarg, $2); # Cycle time push(@retarg, $3); # Rotation state push(@retarg, $4); # Rotation amount }, qr/RL\s*(\d+)([,'"]?)/ => sub { push(@retarg, $1); # Requested cycle time push(@retarg, $2); # VF state }, qr/SA\s+(\d+)/ => sub { push(@retarg, $1); }, # Critical SA qr/DS\s+(\d+)/ => sub { push(@retarg, $1); }, # Critical SA DS ); $_ = {}; @retarg = (); $line =~ s/^\s*//; LOOP: while (length($line)) { for my $k (keys %patterns) { if ($line =~ s/^$k(?:\s+|\z)//) { $patterns{$k}->(); next LOOP; } } warn "Parse_SM_Sub_Header: Error parsing input\n \\$line\\\n"; $_->{leftover} = $line; last; } $_; return(@retarg); } # end Parse_SM_Sub_Header