Getting Started[ edit ] This book assumes that you know absolutely nothing about programming at all and that Perl is your first language.
If you do not specify a package name, the variable is created in the current package. Reference Counts and Mortality Perl uses a reference count-driven garbage collection mechanism. If the reference count of an xV ever drops to 0, then it will be destroyed and its memory made available for reuse.
This normally doesn't happen at the Perl level unless a variable is undef'ed or the last variable holding a reference to it is changed or overwritten.
At the internal level, however, reference counts can be manipulated with the following macros: As a side effect, it increments the argument's reference count. For example, imagine you want to return a reference from an XSUB function. Whenever the returned reference is destroyed, the reference count of the original SV is decreased to one and nothing happens.
The SV will hang around without any way to access it until Perl itself terminates.
This is a memory leak. Then, if and when the last reference is destroyed, the reference count of the SV will go to zero and it will be destroyed, stopping any memory leak. There are some convenience functions available that can help with the destruction of xVs.
These functions introduce the concept of "mortality". An xV that is mortal has had its reference count marked to be decremented, but not actually decremented, until "a short time later".
Generally the term "short time later" means a single Perl statement, such as a call to an XSUB function.
See perlcall and perlxs for more details on these macros. However, if you mortalize a variable twice, the reference count will later be decremented twice. For example an SV which is created just to pass a number to a called sub is made mortal to have it cleaned up automatically when it's popped off the stack.
Similarly, results returned by XSUBs which are pushed on the stack are often made mortal. To create a mortal variable, use the functions: Strange things can happen if you make the same value mortal within multiple contexts, or if you make a variable mortal multiple times.
Stashes and Globs A stash is a hash that contains all variables that are defined within a package. Each key of the stash is a symbol name shared by all the different types of objects that have the same nameand each value in the hash table is a GV Glob Value.
This GV in turn contains references to the various objects of that name, including but not limited to the following: To get at the items in other packages, append the string ":: The items in the Foo package are in the stash Foo::While in most fields Perl adheres to the concept of TMTOWTDI, in accessing relational databases Perl has a de-facto standard library called DBI or Database independent interface for Perl.
Those drivers are compiled together with the C client libraries of the respective database engines. In case of. Perl provides several metacharacters for this. will match a single digit, \w will match any single ``word” character (which, to Perl, means a letter, digit or underscore), and \s matches a whitespace character (space and tab, as well as the \n and \r characters).
PERL API Reference for Network Compliance ManagerCiscoWorks Corporate Headquarters Cisco Systems, Inc. West Tasman Drive San Jose, CA Scribd . ApacheRequestRec also provides auto-generated Perl interface for a few other methods which aren't tested at the moment and therefore their API is a subject .
vile-perl-api -- Vile/Perl interface reference. options making it possible to write "one liners" to operate on the current buffer in much the same way that you might write a one line perl command at the prompt of your favorite shell to operate on a file.
The options even mimic those provided by the perl interpreter, so if you are familiar. mod_perl documentation: This chapter is relevant both to writing a new CGI script or perl handler from scratch and to migrating an application from plain CGI to mod_perl.
mod_perl: CGI to mod_perl Porting. mod_perl Coding guidelines.