There is no hope to give command line examples which would work with
all 3 major shell types...
This is why I avoid posting Perl code in the form
perl -e '...'
It gratuitously involves some shell which may or may not do some
interpolation of its own. The reader must then guess the type of shell
and interpolation (if any) it performs.
If you just post the Perl code:
sub f{ for(1..3) {print $_++ }} f; print q(==); f
it is clear that only the behaviour of perl needs to be considered,
and any shell is irrelevant. To test this, the reader can store it in a
one-line file or use the shell with appropriate quotes.
Besides, if you aren't constrained to one line by the deficiencies of
your shell, you can make the code a bit more readable:
sub f{
for(1..3) {
print $_++
}
}
f;
print q(==);
f
hp