Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

eggzeck (7393)

eggzeck
  (email not shown publicly)

Journal of eggzeck (7393)

Tuesday October 31, 2006
04:29 AM

The auto-increment operator

As I read the perlop manpage (a while back, as everyone should), I find that the auto-increment operator "++" has a bit of built-in magic. Basically: If you use a variable in string context since it was set (other rules apply, read the perlop manpage for more information), the increment is done as a string.

Following these rules, and of course with some creativity, I came up with a way to print my nick "eggzeck"; of course this is for fun, and I'm sharing it for fun/educational purposes. Well, I don't know how much you'll actually learn from this, so it's mostly for fun.

Here's what I came up with:

$nick = join("", map(++($holder = $_), qw(d f f y d b j)));

Pretty cool? The $nick variable will now contain the string "eggzeck". :-)