in reply to Redirect Script unless called from previous script
Take the restricted script out of your web path entirely. Call it as a script from your web executables. Never use any security approach that relies on the referrer, it's not secure.
In Section
Seekers of Perl Wisdom