Assuming you're not hanging on to old versions of Perl, I'd write it as:
given ($_) {
when (/filename\s*=\s*(\S+)/) {$file = basename($1)}
when (/go/ && exists $files{$file}) {
push @PLACE, @batch;
delete $files{$file}
}
@batch = ();
If it's in a for loop, and
$_ is your loop variant, you can even omit the
given.
Thing is, I think I understand what is happening here but not why: essentially, the call to basename() is not finding a good value in $1, which should have been returned from the match by the (\S+).
But you're not matching.
qr// creates a pattern, it does not perform a match.
qr/filename\s*=\s*(\S+)/ is
always true. If you want to match, use
m// instead.