Perl being big on "more than one way to do things...", semicolons are easy to discard:
sub nextq {
my $sz=8;
(print("@_\n"),return) if @_ == $sz;
foreach my $col(0..$sz-1) {
my $row;
if (grep($_==$col,@_)) {next} else {$row=@_}
if (grep($_==$col-$row--,@_)) {next} else {$row=@_}
if (grep($_==$col+$row--,@_)) {next} else {$row=@_}
nextq(@_,$col);
}
}
nextq();