309 ways to do $A++ in Perl

Here is a list of 309 code examples how to increment variable in Perl.

I think that is it very funny, creative and awful at the same time.

As far as I can see, not all code examples are working and not every one is interesting, but some of the solutions are truly magical.

Here is one example created by Maddingue:

#!/usr/bin/perl

eval((map{s/^./\$/,s/ //g;$_}(split"$/",<<'')[-1])[0]);
A
A A + +
A A + +
AAAAAAA +++++++ +++++++
A A + +
A A + +;

print $A;

Here is the full list: https://squareperl.com/en/lots-of-ways-to-increment-variable

Leave a comment

About Ivan Bessarabov

user-pic I blog about Perl.