>
# The following line executes the subroutine "f" and divides the result by 1 on fridays> # but on other days causes the interpreter to trigger a syntax error
You have this the opposite way round to what's happening (and the description). It only compiles on a Friday, i.e. when the sub takes no arguments.
Removing all the "only on a Friday" stuff boils down to the difference between these two:
# this compiles
sub f() {}
f/1;#/+
# this doesn't compile
sub f {}
f/1;#/+
NB. the latter does compile if you take the `+` off the end, when it parses to (using -MO=Deparse)
sub f {}
f /1;#/;
When the sub is declared with zero args, `f` can only compile to mean "call f with no args", thus `/1;#+` means "divide the return value by one, end statement, rest is a comment".
However, when the sub does accept args, `f <stuff>` tries to compile `<stuff>` into arguments to send - and it's a regex pattern `/.../` so the # isn't a comment, it's part of the regex, and the + is where modifiers go - but it's invalid, and is the syntax error. A valid pattern modifier would also compile, e.g.:
sub f {}
f/1;#/m
The argument to `f` here is "whether the pattern /1;#/ matched against $_":
use feature 'say';
sub f { shift ? "matched" : "unmatched" }
$_ = 'this matches 1;#';
say f /1;#/;
$_ = 'this does not match';
say f /1;#/;
Which prints:
matched
unmatched
So, it turns out the + needn't be characterised as an invalid modifier after all - it's just addition with a missing second operand. Add one in and it works as you'd expect:
use feature 'say';
sub f { int shift }
$_='1;#';
say f/1;#/+1 # prints 2