@Zanna If you write one-liners that contain implicit loops with perl -ne
or perl -pe
, and then you convert them to Perl scripts without those options (i.e., which a hashbang line that does not contain the -n
, -p
, or -e
flags), that's a simple way to try it out. That also corresponds to the process of deciding that something is too big or complicated to make a good one-liner, and making a script out of it.
Note that BEGIN
and END
blocks behave differently when neither -n
nor -p
are used--they are very strong, for example the contents of a BEGIN
block run during compilation to bytecode--but you will likely not need them when neither -n
nor -p
are used, because you can just write your code before and after the loop.