in reply to Re^3: How to get current URL with Query String
in thread How to get current URL with Query String

if ($ENV{HTTPS} = "on") {

Already shows a problem with this sort of approach (copying and pasting the “same” snippet around). I don’t doubt you have it right somewhere but that above is a bug (you need eq and you should probably also normalize case with lc). It will always say the URL is https as is.

String concatenation is, to me, code smell. The “no additional modules” shtick can be paraphrased to: no help from experts who have been solving and testing this exact problem against edge cases for 20 years and will continue to do so as the standards are updated.