Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Softpanorama Search

Perl Language

 News

Best Books

Recommended Links Recommended Articles Perl IDE Debugging Perl for Win32

Perl Warts

Perl in Vim Perl as a command line utility tool Perl modules Pipes in Perl Reimplementation of Unix tools Perl philosophy and history Reimplementation of Unix tools  

Namespaces and Modules

grep & map

Sort

Networking

Tips Beautifiers Humor Etc

See Skeptical introduction to Perl for the introduction.

Old News ;-)

[Mar 25, 2006] Beginning Perl  now available in eBook from Perl.com.

This is a very good intro book!.

Namespaces

In the Beginning, some time around 1960, every part of your program had access to all the variables in every other part of the program. That turned out to be a problem, so language designers invented local variables, which were visible in only a small part of the program. That way, programmers who used a variable x could be sure that nobody was able to tamper with the contents of x behind their back. They could also be sure that by using x they weren't tampering with someone else's variable by mistake.

Every programming language has a philosophy, and these days most of these philosophies have to do with the way the names of variables are managed. Details of which variables are visible to which parts of the program, and what names mean what, and when, are of prime importance. The details vary from somewhat baroque, in languages like Lisp, to extremely baroque, in languages like C++. Perl unfortunately, falls somewhere towards the rococo end of this scale.

The problem with Perl isn't that it has no clearly-defined system of name management, but rather that it two systems, both working at once. Here's the Big Secret about Perl variables that most people learn too late: Perl has two completely separate, independent sets of variables. One is left over from Perl 4, and the other is new. The two sets of variables are called `package variables' and `lexical variables', and they have nothing to do with each other.

Package variables came first, so we'll talk about them first. Then we'll see some problems with package variables, and how lexical variables were introduced in Perl 5 to avoid these problems. Finally, we'll see how to get Perl to automatically diagnose places where you might not be getting the variable you meant to get, which can find mistakes before they turn into bugs.

Perl Paraphernalia Understand References Today

© Copyright 1998 The Perl Journal. Reprinted with permission.

One of the most important new features in Perl 5 was the capability to manage complicated data structures like multidimensional arrays and nested hashes. To enable these, Perl 5 introduced a feature called `references', and using references is the key to managing complicated, structured data in Perl. Unfortunately, there's a lot of funny syntax to learn, and the manual is not as clear in this area as it usually is. The manual is quite complete, and a lot of people find that a problem, because it can be hard to tell what is important and what isn't.

Fortunately, you only need to know 10% of what's in the manual to get 90% of the benefit. This article is going to show you that 10%.

[Jul 1, 2005] Perl 5.8 Documentation - BXref - Generates cross reference reports for Perl programs

The B::Xref module is used to generate a cross reference listing of all definitions and uses of variables, subroutines and formats in a Perl program. It is implemented as a backend for the Perl compiler.

The report generated is in the following format: 

    File filename1
      Subroutine subname1
	Package package1
	  object1        line numbers
	  object2        line numbers
	  ...
	Package package2
	...  

Each File section reports on a single file. Each Subroutine section reports on a single subroutine apart from the special cases "(definitions)" and "(main)". These report, respectively, on subroutine definitions found by the initial symbol table walk and on the main part of the program or module external to all subroutines.

The report is then grouped by the Package of each variable, subroutine or format with the special case "(lexicals)" meaning lexical variables. Each object name (implicitly qualified by its containing Package) includes its type character(s) at the beginning where possible. Lexical variables are easier to track and even included dereferencing information where possible.

The line numbers are a comma separated list of line numbers (some preceded by code letters) where that object is used in some way. Simple uses aren't preceded by a code letter. Introductions (such as where a lexical is first defined with my) are indicated with the letter "i". Subroutine and method calls are indicated by the character "&". Subroutine definitions are indicated by "s" and format definitions by "f".

Option words are separated by commas (not whitespace) and follow the usual conventions of compiler backend options.

-oFILENAME
Directs output to FILENAME instead of standard output.
-r
Raw output. Instead of producing a human-readable report, outputs a line in machine-readable form for each definition/use of a variable/sub/format.
-d
Don't output the "(definitions)" sections.
-D[tO]
(Internal) debug options, probably only useful if -r included. The t option prints the objl&

[Jan 2, 2005]  perl_synwrite.vim - checks Perl syntax before allowing file write vim online

This plugin causes write attempts to fail if the contents of the buffer produce an error when run through "perl -c"

The plugin uses can use autocommands for the BufWriteCmd and FileWriteCmd events, but by default only provides a :Write command to check-then-write.
 
install details
Put this file in one of the locations described in :help ftplugin such as "~/.vim/after/ftplugin";  if you want autocommands, which are quirky, define perl_synwrite_au = 1

[Jan 2, 2005] perl.vim - Perl compiler script vim online

This is compiler script that runs perl -Wc and parses all error and warnings. For more information how to use compilers in VIM read help.

This version has workaround with redirecting stderr on windows platform so it can run either on unixes or windows.

Enjoy. Lukas
 
install details
Just put in the $VIMRUNTIME/compiler directory and run :make.

[Dec 26, 2004] http://ppt.perl.org/ Do you know about the Perl Power Tools, at and mirrored various other places?

It is a great project to implement versions of standard Unix tools in pure Perl, so that they can run anywhere Perl does. Those utilities might be perfect for those who like me I prefer Unix/Linux as the development platforms, but Windows for my desktop. They also might be an alternative to the Cygwin stuff even for those who do not use Perl for own scripting. They should be the alternative for those who does use Perl. Once Perl has been installed the PPT stuff only needs to be copied somewhere and that directory added to the PATH. You can also learn some great Perl coding tricks by reading the PPT utilities. Thanks for the anonymous feedback to the Softpanorama for this info.

perl.com Perl Command-Line Options

Perl has a large number of command-line options that can help to make your programs more concise and open up many new possibilities for one-off command-line scripts using Perl. In this article we'll look at some of the most useful of these.

ONLamp.com Which Open Source Wiki Works For You

Kwiki

The Kwiki motto is a "A Quickie Wiki that's not Tricky." Installing it is pretty straightforward for a site you admin: just install the Perl package (from CPAN or elsewhere), and then type kwiki-install in a CGI-served directory to create an instance. Installing Kwiki on a server you are not an admin of is more complicated but doable.

I found the Kwiki markup not powerful. Some things are impossible with it, such as hyperlinking an arbitrary piece of text to an email address (mail fooish). I also could not find how to link a Wiki page with a text link different from the Wiki page name (like this link to LinkedWikiWikiPage). There is also no support for attachments, HTML markup as an alternative to the Wiki markup, etc. It is disappointing.

Kwiki can use either RCS or Subversion for version control. (Those who wish to use Subversion should check out the corrected Kwiki version as the CPAN Kwiki does not work with the up-to-date Subversion.) Kwiki is easily customizable and has several Kwiki enhancements available. Generally, however, they are less powerful than TWiki's.

All in all, Kwiki is easy to install and customize, but its formatting rules are lacking.

... ... ...

UseModWiki

UseModWiki is a Wiki engine written in Perl. Anecdotally, Wikipedia used this first before re-implementing their current engine. Other sites also use UseModWiki.

UseModWiki is very simple to set up and upgrade. It has a rich syntax, and allows for arbitrary characters in page names. It also supports using some HTML tags instead of the WikiWiki markup. It has other nice features, including search, a list of recent changes, and page history.

For simple Wikis, UseModWiki is a very good choice. I recommend choosing between it and PmWiki based on the feature list of both Wikis.

Recommended Links


In case of broken links please try to use Google search. If you find the page please notify us about new location
Google     

Several books are available online: see Perlbooks. 

Book chapters

Actually there are few good online tutorials on Perl.

Some Perl Books sites

Please note that all O'Reilly Perl books have one chapter online. Those chapters are a nice complement to full online books.

Reviews

As for WEB tutorial IMHO only explanation of a particular language features can probably be useful.

Regular expressions (see special section devoted to this important feature below)

References

General

See also modules, regular expressions



Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Disclaimer:

Last updated: August 15, 2009