Ask a Question related to PERL Miscellaneous, Design and Development.
-
Trent Curry #1
Possible bug?; keywords for sub idenifier?
I just wondering, why does Perl allow you to use supposedly reserved words
for a sub (function) identifier?
An example that illustrates this is as follows:
test.pl
----------
#!/usr/bin/perl
package test;
use strict;
$test::Config = new Test_Config;
print $test::Config->my;
print "\n";
----------
Test_Config.pm
----------
package RMS_Config;
use strict;
sub new {
my $this = shift;
my $obj = {
'TEST1' => 1,
'TEST2' => 2
};
bless $obj, $this;
return $obj;
}
sub my {
my $this = shift;
return "test123";
}
1;
----------
Output
----------
[SR@SRLNX test]$ perl -W test.cgi
test123
[SR@SRLNX test]$
----------
Why on earth does it allow reserved names to be used as identifiers? I also
works if tried like this:
test_2.pl
----------
#!/usr/bin/perl
package test;
use strict;
sub my {
print "f o o\n";
}
----------
I get no errors nor warning.
Thanks for any info.
Trent Curry Guest
-
Searching on keywords
Hello, I have a table setup as: +---------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra |... -
Keywords & Description
Hello, I recently built a Contribute enabled site for one of my clients using Dreamweaver templates. My client wants to edit the page keywords... -
keywords and .swf
I have a couple of questions - can more keywords be somehow added into a website? The keyword field only allows 256 characters. I've got about... -
Keywords
Help - I think I am gong mad. In Publisher 2000 I click Web Properties and put some words in Keywords - separated by , - save and upload. When I... -
Need docs on mso- keywords
In web pages created by Publisher, there are these keywords: mso-ignore mso-font-charset mso-paper-source and many others. Where can I find... -
Amir Kadic #2
Re: Possible bug?; keywords for sub idenifier?
Trent Curry wrote:
Why not?> I just wondering, why does Perl allow you to use supposedly reserved words
> for a sub (function) identifier?
Can you imagine any trouble resulting from it
(except for human-unreadable code)
?
The interpreter knows what you mean when you call
a method on a blessed reference, doesn't it?
It also has no trouble with main::my, &my, or &my(),
but it will give up when you say just my(), so everything
is just perfect, IMHO.
Amir
Amir Kadic Guest
-
Trent Curry #3
Re: Possible bug?; keywords for sub idenifier?
"Amir Kadic" <zoooz@gmx.de> wrote in message
news:bjgjav$ip512$1@ID-142982.news.uni-berlin.de...words> Trent Curry wrote:
>> > I just wondering, why does Perl allow you to use supposedly reservedSo its actually a feature then? Just seems rather odd when you've been>> > for a sub (function) identifier?
> Why not?
> Can you imagine any trouble resulting from it
> (except for human-unreadable code)
> ?
>
> The interpreter knows what you mean when you call
> a method on a blessed reference, doesn't it?
>
> It also has no trouble with main::my, &my, or &my(),
> but it will give up when you say just my(), so everything
> is just perfect, IMHO.
>
> Amir
through so many other langs (c/c++/java/cobol/PL-SQL/and the likes). Its an
interesting feature though. Perl is a lang that never ceases to amaze me :-)
Trent Curry Guest



Reply With Quote

