Why is DESTROY in all caps? Perl on occasion uses purely uppercase function names as a convention to indicate that the function will be automatically called by Perl in some way. Others that are called implicitly include BEGIN, END, AUTOLOAD, plus all methods used by tied objects, described in the perltie manpage.
[ add comment ] | permalink |




( 3 / 62 )Like the special per-package variables recognized by Exporter (such as @EXPORT, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, and $VERSION), the @ISA array must be a package-scoped global and not a file-scoped lexical created via my(). Most classes have just one item in their @ISA array. In this case, we have what's called ``single inheritance'', or SI for short.
Consider this class:
package Employee;
use Person;
@ISA = ("Person");
1;
Not a lot to it, eh? All it's doing so far is loading in another class and stating that this one will inherit methods from that other class if need be. We have given it none of its own methods. We rely upon an Employee to behave just like a Person.
[ add comment ] | permalink |




( 3 / 65 )sub new {
my $self = {};
$self->{NAME} = undef;
$self->{AGE} = undef;
$self->{PEERS} = [];
bless ($self);
return $self;
}
[ add comment ] | permalink | related link |




( 2.8 / 78 )Autovivification is a distinguishing feature of the Perl programming language involving the dynamic creation of data structures. Autovivification is the automatic creation of a variable reference when an undefined value is dereferenced. In other words, Perl autovivification allows a programmer to refer to a structured variable, and arbitrary sub-elements of that structured variable, without expressly declaring the existence of the variable and its complete structure beforehand.
In contrast, other programming languages either: 1) require a programmer to expressly declare an entire variable structure before using or referring to any part of it; or 2) require a programmer to declare a part of a variable structure before referring to any part of it; or 3) create an assignment to a part of a variable before referring, assigning to or composing an expression that refers to any part of it.
[ add comment ] ( 1 view ) | permalink | related link |




( 3 / 43 )If I do a LEFT JOIN, I get all records that match in the same way and IN ADDITION I get an extra record for each unmatched record in the left table of the join - thus ensuring (in my example) that every PERSON gets a mention:
mysql> select name, phone, selling
from demo_people left join demo_property
on demo_people.pid = demo_property.pid;
If I do a RIGHT JOIN, I get all the records that match and IN ADDITION I get an extra record for each unmatched record in the right table of the join - in my example, that means that each property gets a mention even if we don't have seller details:
mysql> select name, phone, selling
from demo_people right join demo_property
on demo_people.pid = demo_property.pid;
An INNER JOIN does a full join, just like the first example, and the word OUTER may be added after the word LEFT or RIGHT in the last two examples - it's provided for ODBC compatibility and doesn't add an extra capabilities.
[ add comment ] ( 1 view ) | permalink | related link |




( 3 / 35 )There are rare occasions when you do want to export methods or variable names into the calling package. I only do this occasionally for static helper methods I need very, very often. In order to export symbols, inherit from the Exporter class and fill the @EXPORT array with the symbols you'd like to export:
package Util;
use base 'Exporter';
our @EXPORT = ('foo', 'bar');
Try not to pollute another package's namespace unless you have a very good reason for doing so! Most packages on CPAN explicitly state which symbols get exported with their use, if any.
It might be a good idea to leave it up to the requiring package to decide which symbols get exported into its namespace. In that case you simply use the @EXPORT_OK array instead or @EXPORT.
package Util;
use base 'Exporter';
our @EXPORT_OK = ('foo', 'bar');
[ add comment ] ( 1 view ) | permalink | related link |




( 3 / 20 )USE
Imports some semantics into the current package from the named
module, generally by aliasing certain subroutine or variable
names into your package. It is exactly equivalent to
BEGIN { require Module; import Module LIST; }
except that Module *must* be a bareword.
The "BEGIN" forces the "require" and "import" to happen at
compile time. The "require" makes sure the module is loaded into
memory if it hasn't been yet. The "import" is not a
builtin--it's just an ordinary static method call into the
"Module" package to tell the module to import the list of
features back into the current package. The module can implement
its "import" method any way it likes, though most modules just
choose to derive their "import" method via inheritance from the
"Exporter" class that is defined in the "Exporter" module. See
Exporter. If no "import" method can be found then the call is
skipped.
REQUIRE
Otherwise, demands that a library file be included if it hasn't
already been included. The file is included via the do-FILE
mechanism, which is essentially just a variety of "eval". Has
semantics similar to the following subroutine:
sub require {
my ($filename) = @_;
if (exists $INC{$filename}) {
return 1 if $INC{$filename};
die "Compilation failed in require";
}
my ($realfilename,$result);
ITER: {
foreach $prefix (@INC) {
$realfilename = "$prefix/$filename";
if (-f $realfilename) {
$INC{$filename} = $realfilename;
$result = do $realfilename;
last ITER;
}
}
die "Can't find $filename in \@INC";
}
if ($@) {
$INC{$filename} = undef;
die $@;
} elsif (!$result) {
delete $INC{$filename};
die "$filename did not return true value";
} else {
return $result;
}
}
Note that the file will not be included twice under the same
specified name.
The file must return true as the last statement to indicate
successful execution of any initialization code, so it's
customary to end such a file with "1;" unless you're sure it'll
return true otherwise. But it's better just to put the "1;", in
case you add more statements.
[ add comment ] ( 1 view ) | permalink |




( 3 / 20 )Firefox
1. Select menu [Tools]
2. Select menu item [Options].
3. Select tab [General].
4. Click button [Languages].
5. Click drop-down-box [Select a language to add..]
6. Mark a language e.g. English (United Kingdom) and click [Add].
7. Use button [Move Up], to place your language at the top of the list.
8. Click [OK] twice.
9. Reload webpage (e.g. by [F5]).
Internet Explorer
1. Select menu [Tools]
2. Select menu item [Internet Options].
3. Select tab [General].
4. Click button [Languages].
5. Click button [Add...]
6. Mark a language e.g. English (United Kingdom) and click [OK].
7. Use button [Move Up], to place your language at the top of the list.
8. Click [OK] twice.
9. Reload webpage (e.g. by [F5]).
Opera
1. Select menu [File]
2. Select menu item [Preferences...].
3. Select category [Languages].
4. Click button [Add...]
5. Mark a language e.g. English (United Kingdom) and click [OK].
6. Use button [Move up] to place your language at the top of the list.
7. Click [OK] twice.
8. Reload webpage (e.g. by [F5]).
Netscape Navigator 4.x
1. Select menu [Edit]
2. Select menu item [Settings].
3. Select category [Navigator/Languages].
4. Click button [Add...]
5. Mark a language e.g. English (United Kingdom) and click [OK].
6. Use arrow button to place your language at the top of the list.
7. Click [OK]
8. Reload webpage (e.g. by [Ctrl+R]).
[ add comment ] ( 1 view ) | permalink | related link |




( 3 / 10 )http://ipinfodb.com/ip_database.php
[ add comment ] ( 1 view ) | permalink | related link |




( 3 / 14 )Adding a cookie
use CGI;
$query = new CGI;
$cookie = $query->cookie(-name=>'MY_COOKIE',
-value=>'BEST_COOKIE=chocolatechip',
-expires=>'+4h',
-path=>'/');
print $query->header(-cookie=>$cookie);
Reading cookie:
$theCookie = $query->cookie('MY_COOKIE');
[ add comment ] ( 1 view ) | permalink | related link |




( 3 / 14 )
Calendar



