SimpleTemplate 0.84, 9292 63 bytes
This challenge was simple, yet fun!
Simply checks if the input is just "hhh...." and outputs the text, or throws an exception with the contentoutputs "err". to STDOUT:
{@ifargv.0 matches"@^h+$@"M}{@eachM.0}Hello World{@/}{@else}{@phpthrow new Exception("err")}err
There is no built-in to throw an exception, so, I had to resortThe big byte saving was due to PHP.
If just outputting err
to STDOUT is fine, this can be reduced to 63 bytesthe-cobalt's comment:
{@ifargv.0 matches"@^h+$@"M}{@eachM.0}Hello World{@/}{@else}err
Outputting to STDOUT is fine, so you could use your 63 byte version.
Ungolfed:
Below is a more readable version of the code:
{@if argv.0 matches "@^h+$@"}
{@each argv.0 as h}
{@echo "Hello World"}
{@/}
{@else}
{@php throw new@echo Exception("err")}
{@/}
You can try this on: http://sandbox.onlinephpfunctions.com/code/0f87b846cadde59a01a9fae12b924ce3a406a4c6http://sandbox.onlinephpfunctions.com/code/e35a07dfbf6b3b56c2608aa86028b395ef457129