Does your code compile? O.o
Anyways, I think you might be overcomplicating things. This seems to do what you want:
my @stu = (
'103_dsu 1 35 nbu103',
'104_dsu 1 35 nbu104',
'204_tape 1 1 ACS1',
'101_dsu 1 35 nbu101',
);
my @dp = (
'nbu103 Disk 6 -1',
'nbu104 Disk 6 -1',
'nbu101 Disk 6 -1',
);
foreach my $stu (@stu) {
my (undef, undef, undef, $possible) = split ' ', $stu;
my ($matched_dp) = grep {
my ($dp) = split ' ', $_;
$dp eq $possible
} @dp;
$stu = $matched_dp if $matched_dp;
}
use Data::Dumper;
print Dumper(@stu);