Magic $a $b



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
.



Relevant Pages

  • Re: SMN Cuisine - Seal
    ... I can't call the tech line? ... :> After that Perl of wisdom I think I'll AWkwardly remain silent Less I ...
    (sci.military.naval)
  • Re: why the perl documents is hard to understand?
    ... Also sprach Gunnar Hjalmarsson: ... >> complain about certain aspects of perl, be it the use of seemingly ... > What kind of wisdom do you read in statements similar to "the docs are bad"? ...
    (comp.lang.perl.misc)
  • Re: Perl and Internet Explorer
    ... > wisdom, they've programmed IE to ignore MIME types. ... It has nothing to do with Perl. ... headers you can send to try to clarify things for the browser, ...
    (comp.lang.perl.misc)
  • Re: Perl and Internet Explorer
    ... > wisdom, they've programmed IE to ignore MIME types. ... It has nothing to do with Perl. ... headers you can send to try to clarify things for the browser, ...
    (microsoft.public.powerpoint)
  • Re: is there a way ..... any way
    ... is that clpm is not really considered to be a newsgroup about how to ... program in perl, or about how to install perl, and especially not a ... newsgroup about how to program in general (happening to use perl as the ... I tried doing that with this bit of code, Z, I got back a response ...
    (comp.lang.perl.misc)