A
Achim Peters
Hi,
I'm a noob to perl and a frequent reader of this group. Whenever anyone
in here uses $a and/or $b in a non-sort context s/he gets a "Don't!
They're magic." as a response. Now, I believe in magic and the wisdom of
regulars and that's why I mentioned this general rule in
de.comp.lang.perl.misc.
But there happened to be a non-believer and he dared me with "Oh,
really? Perl this:"
use strict;
use warnings;
$a = 4711;
my @arr = qw /x a u q r/;
@arr = sort { $a cmp $b } @arr;
print "$a\n";
which in fact does print the 4711 (a German "magic" number) with Perl
5.8.2, thus no side effects of the sorting (except of course that the
missing "my" in front of $a does not cause an compile error.
Is there any example to prove his impertinence of questioning the gurus'
wisdom?
TIA
Bye
Achim
I'm a noob to perl and a frequent reader of this group. Whenever anyone
in here uses $a and/or $b in a non-sort context s/he gets a "Don't!
They're magic." as a response. Now, I believe in magic and the wisdom of
regulars and that's why I mentioned this general rule in
de.comp.lang.perl.misc.
But there happened to be a non-believer and he dared me with "Oh,
really? Perl this:"
use strict;
use warnings;
$a = 4711;
my @arr = qw /x a u q r/;
@arr = sort { $a cmp $b } @arr;
print "$a\n";
which in fact does print the 4711 (a German "magic" number) with Perl
5.8.2, thus no side effects of the sorting (except of course that the
missing "my" in front of $a does not cause an compile error.
Is there any example to prove his impertinence of questioning the gurus'
wisdom?
TIA
Bye
Achim