configure: Fix checking for perl

Closes #1196
Fixes #1197