Revert "perl: simplify code to load scripts"

This reverts commit 793a3cb1bad053ac3366cc34775dbc9b1e9ffb8a.

This commit was causing crash on Linux when loading scripts like buffers.pl.