First of all, you can use
/x to make that wall of code a lot more readable.
Secondly, you can test the result of the match to verify that you really got 19 values out:
my $result =
(($beginning, $agency, $district, $ssn, $serv_per_m,
$serv_per_y, $serv_per_t, $last_name, $first_name_i,
$middle_name_i, $cover_group, $pay_code, $pay_rate,
$earnings, $holder, $ret_percent, $surv_ben,
$work_sch_code, $cont_amt, $cont_code, $stuff) =
/
(\d) # $beginning
(\d{4}) # $agency
(\d{3}) # $district
(\d{9}) # $ssn
(\d{2}) # $serv_per_m
(\d{2}) # $serv_per_y
(\d) # $serv_per_t
(\D{10}) # $last_name
(\D) # $first_name_i
(\D) # $middle_name_i
(\d{5}) # $cover_group
(\d{2}) # $pay_code
(\d{8}) # $pay_rate
(\d{6}\D) # $earnings
(\s{8}) # $holder
(\d{4}) # $ret_percent
(\d{3}) # $surv_ben
(\d{3}) # $work_sch_code
(\d{5}\D) # $cont_amt
(\d{2}) # $cont_code
(.*\s) # $stuff
$
/x
);
if ($result == 21) {
# Test the variables
} else {
# This line did not match
}