Perl Syntax
Andrew Hammond
ahammond-swQf4SbcV9C7WVzo/KQ3Mw at public.gmane.org
Tue May 24 20:36:54 UTC 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Taavi Burns wrote:
> On 5/24/05, Peter <plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org> wrote:
>
>>On Mon, 23 May 2005, John Vetterli wrote:
>>
>>
>>>So is the "INT" in $SIG{INT} a string literal (i.e. is it really $SIG{"INT"})
>>>or a variable name? Or is it something else?
>>
>>It stays for SIGINT which is a symbol name that is equivalent to the
>>code of the interrupt signal. In Perl it need not be a number (Perl uses
>>hashes - i.e. SIGINT is simply a key in a database of tuples).
>
>
> However, being a bareword (no sigil, not in the context of a file
> handle, and not a number) it's interpreted as a string and $SIG{INT}
> should be equivalent to $SIG{"INT"} and equivalent to $SIG{'INT'}.
That is what's happening in this case. IMHO, barewords are evil and
should not appear in documentation except as examples of the "hackish"
solution.
This also looks like another pretty common trick, the zero parameter
inline function. This is often used to represent constants. Example follows.
sub INT () { 2 }
If you're learning perl, the best advice I can give you is to start
every single one of your programs with "use strict;", which will not
allow you to use barewords. It can save you from developing some
particularly bad habits.
- --
Andrew Hammond 416-673-4138 ahammond-swQf4SbcV9C7WVzo/KQ3Mw at public.gmane.org
Database Administrator, Afilias Canada Corp.
CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCk5Blgfzn5SevSpoRAi97AKC7NmfP8LsQePlIASMgITYVDeFIZwCbBo5A
pjKJl1jB4430Ftr+dMptmlU=
=ByDJ
-----END PGP SIGNATURE-----
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list