T
Trent Curry
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";
}
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";
}