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

Contents Bulletin Scripting in shell and Perl Network troubleshooting History Humor

Perl IDE and Programming Environment

Version 1.2 (June 15, 2015)

News

Chapter 1

Recommended Links Recommended Articles Perl in
command line

More Complex Perl Regular Expressions

Perl debugger Perl Lint Perl Xref Editors Perl Prettyprinting Perl Syntax Error Checklist
Perl POD documentation          

Perl Style

Html converters

Tips

Humor Random Findings  Etc

Introduction

Great tools will never convert a bad programmer into a good programmer, but they will certainly make a good programmer better and they can make a bad language acceptable (Java is one such example).

A good, modern IDE should include interface to the following components:

There are two ways of approaching Perl IDE question

All language have quirks, and all inflict a lot of pain before one can adapt to them. Once learned the quirks become incorporated into your understanding of the language. But there is no royal way to mastering the language. The more different is one's background is, more one needs to suffer. Generally good environment can compensate for some pitfalls int he language. Syntax highlighting is one such feature.

When mastering a new language first you face a level of "cognitive overload" until the quirks of the language become easily handled by your unconscious mind. At that point, all of the sudden the quirky interaction becomes a "standard" way of performing the task. For example regular expression syntax seems to be a weird base for serious programs, fraught with pitfalls, a big semantic mess as a result of outgrowing its primary purpose. On the other hand, in skilled hands its a very powerful tool that can serve a parser for complex data and a substitute for string functions.

There are three notable steps in adaptation to Perl idiosyncrasies for programmers who got used to other languages:

  1. One early sign is when you start to put $ on all scalar variables automatically.  Most such cases are diagnosed by interpreter but some like $location{city} are not
  2. The next step is to overcome notational difficulties of using different two operations (like "==" for numbers vs eq for strings) for comparison numbers and strings. In case two variables are involved, the interpreter does not provide any warnings so you need to be very careful as if you use other language in parallel with Perl such errors crop into your scripts automatically. If one of the operators of "==" is a string constant automatic diagnostic can be provided.
  3. Conscious use of "==" as equality predicate for numbers, if you previous language allowed to used "=" for checking equality or assignments. The pitfall of using "=" for assignment, which results in side effect of introducing errors in comparisons  if ($a=1)...  instead of if  ($a==1) was understood by designers on Algol 60, which was designed is late 50th. To avoid it they used := for assignment instead of plain =. But designers of Fortran, PL/1 and later C as derivative of PL/1 ignored this lesson (actually Fortran predates Algol 60 so its designer were pioneers and are not guilty). As Fortran and C became dominant programming languages we have what we have.  Now talk about progress in programming language design if the design blunder about which designers knew 65 years ago still is present today ;-). So in all languages that have lexical structure of C it remains the  most rich source of subtle errors for novices. Naturally this list includes Perl.  As it it also present in C and C++, so C programmers are already trained to be aware about  this language pitfall ( if (a=1)... is as bad in C as in Perl) and are less affected.  Protective measures
    1. modify syntax highlighting so that such cases were marked in bold red.
    2. Manually or automatically (simple regex done in the editor can do 99% of cases) reorganoze such comparisons putting the construct on the left part of comparison, like in  if (1==$a)....
    3. Recent versions of Perl interpreter provide warning in this case so checking your script with option -cw also helps if IDE provides capability to display of results of checking of syntax in one of the windows and jumpt to the line in code listed in the error or warning (this is a standard feature of all IDEs and actually this can be done in most editors too). 

 

Known attempts to create integrated Perl IDE

Currently there is no good Perl IDE. There were several attempts to create one of different quality and sustainability but none of the projects proved to be sustainable.

With Perl now by-and-large having very limited by lack of financial support from big corporations (support that both PHP and Python enjoy) is unrealistic to expect that there will be many offerings. May be only open source offering will survive as there not much money to make in distributing a commercial Perl IDE or editor. So commercial versions tend to die like files on the frost. No surprise that Microsoft does not support Perl in Visual Studio. 

Many promising projects of Perl IDE are stalled or became abandonware. Here I would like to warn you: a danger of choosing an IDE (or editor) that goes nowhere is real and is one of the most painful mistakes programmer can make. So the key in choosing here is stability and longevity. It takes a couple of years to master IDE (especially editor) and this investment should pay dividends the rest of your career. So chose wisely.

A simple check is to see if the web page discusses compatibility of the product with 64-bit version of Windows helps to determine if the development is continued. If not, then chances are that the development stopped a long time ago. Two products that are maintained and updated are Komodo and Perl builder. It looks like others are in various stages of abandonment. For open source products this is less critical as there is always a forum and most critical problems eventually get fixed. If user community is small this can be painfully slow. Or you can fix them yourself (possibility if the IDE is written in Perl like Padre (http://padre.perlide.org/).

But there is variety. In this sense my findings actually surprised me. There are some choices and some reasonably good choices do exist. Among them:

See also:

Assembling your own IDE from custom components

There are quality components that constitute IDE and another approach is to integrated them in "poor man IDE" using some suitable approach.  there are two simple possibilities:

Use a programmable editor for integration

You can use the programmable editor as the integration framework (most programmable editors allow to invoke external programs as macros and even allow redirecting output of the program into editor windows. SlickEdit, Kedit Gvim and Emacs are good examples of editors with those capabilities.

Advanced users of Emacs typically use this approach. Execution of script of a selection or total editing buffer is another powerful instrument of creating your own IDE. Both vim and Komodo editor 6 (unfortunately it was removed in Komodo editor 7) permit this. This way it is easy to implement brace counter, simple beautifier, etc. Also if you assemble your own IDE from components you can use the editor you already know and use. Actually the quality of editor is a very important consideration here. If should support syntax highlighting, split view of editing buffer, ability to execute scripting on editor buffer (like !! in vi. see Piping Vim Buffer Through Unix Filters: ! and !! Commands).

 would like to stress that the choice of editor is critical: many programmers are hampered by betting used to a simplistic editor that does not provide enough power for productive development (some pretty gifted programmers use Pico or notepad or a similar light-weight editor without folding, split screen support, syntax highlighting and checking, ability to execute scripts on the buffer, etc.  Like Talleyrand used to say this is worse that a crime, this is a blunder ;-). And while features listed above are a must,  generally a good editor for developer should be able to do more. See below description of SlickEdit and Gvim -- two prominent representatives of families of editors tuned to developers needs.

Perl developers have several options none of which is perfect. Beware guys who advocate primitive lightweight editors. As editor is such an important tool it makes perfect sense to pay small amount of money for it. But you need to be sure about the longevity of the vendor. Switching editors is a very painful process. That means that free editors do not have an inherent advantage over commercial for developers as long as the price is not too steep, say, less then $100.  Open source editors do have some advantage because of better staying power, but you can benefit from availability of open source only if you know well the language in which the editor is written and have time to tweak or debug it. Few people do. The real problem is the quality, features, longevity and portability of the editor.

I personally prefer editors that support command line command set. I call this class of editors "orthodox editors" and it has two prominent branches -- eastern (XEDIT, Kedit, THE, SlickEdit, etc, see Eastern Orthodox Editors) and western (vi, vim, gvim, etc). See Orthodox Editors for discussion of this class of editors.

As for longevity here for both free and commercial editors there no guarantee with the possible exception of VIM and THE which have established user populations and most probably will survive another 50 years. Here are some selections that can at least be tried:

VIM and GVIM

One possible "poor man IDE" is VIM and, especially GVIM. The key advantage that system administrators already know it, although typically just small, very restricted subset.

Vim is not as great as specialized IDS but still you can achieve quite a lot by careful customarization.  VIM provides syntax highlighting coding for Perl. The most important thing to learn are first additional  ctags.

Vim has the following important features:

When using tags it is nice to have two windows split horizontally. Vim supports both vertical and horizontal window splitting. To split current window horizontally execute “:split” while in the normal mode. To split current window vertically, use “:vsplit” instead. If you don’t provide any filename as argument to split/vsplit then current filename is used. You further split resulting windows as much as you like. Use Ctrl-w w to cycle through the windows. “:close” will close the current windows. “:only” will close all windows except the current one.

Vim provides  facilities for reconciling differences between two “vimdiff main.pl main2.pl” (or “vim -d main.pl main2.pl“) from the command line to see difference made to file main.pl in file main2.pl.

Vim will show both files in vertical split window mode. When you will scroll in one window, Vim will automatically scroll another window for you. You can patch the individual differences using do and dp commands. do will get the patch from the neighbor window and apply it to the current buffer, while dp will apply the difference from the current buffer to the neighbor window. If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/diff.txt.

Here is an excellent article of Leonid Mamchenkov Vim for Perl developers (May.10, 2004). Although written more then 5 years ago it is still the best intro into VIM facilities for Perl users. Below is an abbreviated version with some updates:

Text wrapping

As you code, sometimes text flows further than the width of the editor window. Some people like long lines to be wrapped (in other words, continued on the other line), while others prefer them unwrapped. You can configure Vim to behave according to your liking by adding “set wrap” or “set nowrap” to your .vimrc configuration file.

Flexible tabs

Tabulation is one of the hottest topics in programmers discussions when it comes to style. A very nice explanation of what is the problem with tabulations and spaces can be read at http://www.jwz.org/doc/tabs-vs-spaces.html. I must say though, that I don’t agree with author’s position on the subject. The article does provide you with several options for vi/Vim configuration to control the behavior of the tabs. I will just add/repeat the ones I consider important.

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/indent.txt.

Line numbering

While Vim always displays your current position in the status line, you might also want to see all lines numbered. To do that, you will need to add “set number” to your .vimrc.

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/usr_03.txt.

Syntax highlighting

The first thing any developer will notice in Vim is excellent syntax highlighting. All popular languages are supported. Syntax files for less popular are available from Vim web site. Perl is supported out of the box.

Vim identifies keywords, comments, variables, strings, in-line POD and other standard parts of the program and highlights them. Vim supports two color modes: one for terminals with dark background color and another one for terminals with light background color. You can control these modes by specifying command “set bg=dark” and “set bg=light” in your .vimrc.

If you still don’t like the appearance of the code, stay tuned until “Color schemes” discussion.

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/syntax.txt.

Text completion

One of Vim’s features I cannot live without is text completion. When editing, press Ctrl-n / Ctrl-p to cycle through the current word completion suggestions. Vim generates suggest list based on the words in the current file. If you need key completion to make suggestions from other files, then Vim by default understand the ctags file. Simply run “ctags *.p?” to generate ctags for all Perl files and modules in the current directory (assuming you are using “.pl” extension for Perl scripts and “.pm” extension for Perl modules). This Vim’s feature not only saves a tonne of time on typing, but greatly decreases the error rate, especially with long variable and procedure names in the code.

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/usr_24.txt.

File Completion

While you are in the command mode, Vim can complete the names of files and directories in case you want to open or save a file. In order to complete a file or a directory name you should start typing it’s name on the command prompt and then press the completion key. You can change the completion key to be almost anything you want with “set wildchar=” line in your .vimrc file.

Window splitting

Sometimes I need to see two or more files simultaneously. While I can always start another Vim session in a separate terminal, it is not as comfortable at times as Vim’s window splitting feature.

Vim supports both vertical and horizontal window splitting. To split current window horizontally execute “:split” while in the normal mode. To split current window vertically, use “:vsplit” instead. If you don’t provide any filename as argument to split/vsplit then current filename is used. You further split resulting windows as much as you like. Use Ctrl-w w to cycle through the windows. “:close” will close the current windows. “:only” will close all windows except the current one.

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/usr_08.txt.

Diff mode

Vim provides excellent facilities for checking and editing differences between two or more files. Execute “vimdiff main.pl main2.pl” (or “vim -d main.pl main2.pl“) from the command line to see difference made to file main.pl in file main2.pl.

Vim will show both files in vertical split window mode. When you will scroll in one window, Vim will automatically scroll another window for you. You can patch the individual differences using do and dp commands. do will get the patch from the neighbor window and apply it to the current buffer, while dp will apply the difference from the current buffer to the neighbor window.

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/diff.txt.

Text folding

Yet another popular feature found in popular editors and IDEs is text folding. I think that folding is easier shown then explained. Vim supports six folding methods: by indent, by expression, by syntax, by changes in the text, by marker, and manual folding. For the sake of the example, I will show how to configure folding by marker.

In order to tell Vim to use folding by marker add the following lines to your .vimrc:

" Folding configuration
set foldmethod=marker
" Edit and uncomment next line if you want non-default marker
"set foldmarker="{{{,}}}"

If you need more information on this topic, read files /usr/share/doc/vim-common-6.1/docs/usr_28.txt and /usr/share/doc/vim-common-6.1/docs/fold.txt.

Marks

One of Vim’s features that speeds up navigation is – marks. You can set a mark anywhere in the text and then quickly jump back to it. You can set several marks. You can set marks in several files and then quickly switch between them. I find myself set mark on the place I am currently working at with mc (m is for “mark”, c I use for “current”) and then quickly returning to the same place with 'c.

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/motion.txt.

Vertical Indent Display

For some people indenting text horizontally is not enough. They need some kind of vertical indentation to help them see corresponding parts of the code. While I am not one of those people, I’ve seen this feature around so often that I decided to add it codemonkey’s .vimrc.

All you need to do to have vertical indent display with pipe (”|”) character is to add the following two lines to your .vimrc.

" This is for vertical indenting
set list
set listchars=tab:|
" NOTE the space char after last backslash.

:set list” forces Vim to show hidden characters like tabulations, ends of lines, and ends of files. “:set listchars=tab:| ” asks Vim to show only tab characters and use a pipe (”|”) with a space (” “) to do so, instead of usual “^I” thing that Vim likes to show.

Color schemes

Robert (MetaCosm) downloaded all color schemes and put them into a single archive file which he uploaded back to Vim’s web site (http://www.vim.org/scripts/script.php?script_id=625.).

You will most likely notice that some color schemes do not change much colors in your console vim. That is because they are most probably designed for GUI version of Vim, called gvim.

Try executing “gvim +'colorscheme peachpuff' main.pl” to see how gvim looks with selected color scheme.

Now you can try all those color schemes one by one with “:colorscheme something” and choose the one you like best. When you are done choosing, add line “colorscheme something” to your .vimrc.

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/usr_06.txt.

Block commenting

It is an often need to comment or uncomment blocks of code during the development cycle. While there is a way to do it in Vim without any additional configuration, I try to make life as easy as possible and install the BlockComment plug-in by Chris Russell.

Let’s download BlockComment.vim from http://www.vim.org/scripts/script.php?script_id=473 and copy it into .vim/plugin/ directory. This plug-in automatically provides us with two mappings: “.c” for commenting code and “.C” for uncommenting code back.

File and buffer browser

Vim supports editing of several files simultaneously. One can start Vim as “vim main.pl main2.pl” and then use “:next” and “:previous” to navigate through open files (called “buffers”). It is also possible to open files for editing without quiting Vim every time. For that, one should use simple “:e main2.pl” command, where main2.pl is the name of needed file.

There are, as usual, better (more convenient) ways to work with files and buffers. Vim website lists few plug-ins which can handle only files, or only buffers, or both at the same time. One of those plug-ins is winmanager by Srinath Avadhanula. Let’s grab winmanager from http://www.vim.org/scripts/script.php?script_id=95.

Vim’s winmanager plug-in can make use of bufexplorer plug-in by jeff lanzarotta availalbe from http://www.vim.org/scripts/script.php?script_id=42.

Installation is as usual – saving, unziping, and dos2unixing. Since we don’t want to always have file/directory browser turned on, lets add a mapping line to our .vimrc to “:WMToggle” by F2.

" This is for winmanager
map <F2> :WMToggle<CR>

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/usr_23.txt.

Tag explorer

If you ask me, I am almost happy. The last thing that I am missing is something that will ease up my code browsing. I need a fast way of switching between different parts of my code and hierarchical view of it. Once again I go fishing to Vim web site and get myself a nice looking taglist plug-in by Yegappan Lakshmanan from http://www.vim.org/scripts/script.php?script_id=273. This one is not even an archive! You just need to copy it into your .vim/plug-in directory. Let’s map “:Tlist” command to F3 key.

" This is for taglist
map <F3> :Tlist<CR>

One annoying thing that I find about taglist is that it resizes the terminal window when possible. I prefer to switch this feature off by add modifying my .vimrc in the following way.

" This is for taglist
let Tlist_Inc_Winwidth = 0
map <F3> :Tlist<CR>

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/tagsrch.txt.

Perl syntax checking

..copy perl.vim (developed by Lukas Zapletal) into your .vim/compiler/ directory. Now we need to specify for which files we want Vim to use our new perl compiler scripts. This is easily done by adding the following lines to .vimrc.

" Use perl compiler for all *.pl and *.pm files.
autocmd BufNewFile,BufRead *.p? compiler perl

Now you can use “:make” to check your code for errors. If you do have problems in your code, then Vim will position the cursor on the line with the first problem. You can use “:cnext” and “:cprevious” to go through other error messages. “:clist” will show a list of all errors.

If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/usr_30.txt.

 You can also check perl syntax in VIM on each save

au BufWritePost *.pl,*.pm !perl -c %

With this macro every time you save a .pl or .pm file, it executes perl -c and shows you the output.

Perldoc integration

Yet another feature provided in most IDEs is on-line documentation. Vim helps developers even with that. By default, Vim comes with system manual support on all UNIX boxes. This comes very handy when you use system commands in your scripts and need to check command line parameters. Just position the cursor on the word that you are interested in and press K. Vim will execute “man word“, where “word” is the word under the cursor. This is helpful but not as much as we need it.

Let’s visit Vim site again and download Perldoc plug-in (developed by Colin Keith) from http://www.vim.org/scripts/script.php?script_id=209. unzip perldoc.zip and run all extracted files through dos2unix. It’s a good idea to add a F1 mapping to “:Perldoc” in your .vimrc.

" This is for perldoc.vim
autocmd BufNewFile,BufRead *.p? map <F1> :Perldoc<cword><CR>
autocmd BufNewFile,BufRead *.p? setf perl
autocmd BufNewFile,BufRead *.p? let g:perldoc_program='/usr/bin/perldoc'
autocmd BufNewFile,BufRead *.p? source /home/codemonkey/.vim/ftplugin/perl_doc.vim

If you are using a newer version then I do, then you skip the last line.

Now, whenever you hit F1 while in the perl file, “:Perldoc” will get executed for the word that you have under the cursor, your current window will split horizontally and you’ll see appropriate perldoc page.

After installation of this plug-in I have noticed that syntax highlighting in few of my programs broke. After a quick look, I understood that that happened because of my extensive usage of underscore (”_”) character in procedure names. I had to fix it by simply adding underscore (”_”) character to the list of keyword characters on line 14 in file .vim/ftplugin/perl_doc.vim.

" Adds / and . as used in requires.
" setlocal iskeyword=a-z,A-Z,48-57,:,/,.
" Adds / and . as used in requires. Also adds _ as used in procedure names.
setlocal iskeyword=a-z,A-Z,48-57,:,/,.,_

Komodo Editor

Komodo editor does not have built-in macro language but other then that it is a average editor

The key features include:

DzSoft Perl Editor

DzSoft Perl Editor ($49) is a good editor for Perl. It has built-in debugging features, a simple editor with syntax highlighting, a syntax check feature that finds errors in your script. Here is the list of features from the site:

Notepad++

Notepad++ is a free simple editor which provides Perl syntax highlighting and basic editing features. I use it personally and its OK for small scripts. For larger scripts you need more full-fledged editor like SlickEditor.

Use of Orthodox File Manager for integration

Another simple way to integrate those components is to use orthodox file manager (OFM) such as Midnight commander in Linux, Far and Total Commander in Windows. Detail depends on capability of particular OFM and your imagination. You can also write you own plug-ins for the purpose. Here is some ideas from my own experience:

Running Perl in diagnostic mode

With OFMs it is possible to run Perl in diagnostic mode (options -cw) with one keystroke. You can bind this command to letter c in user menu. For example for FAR the command would be something like: 

c:\cygwin\bin\perl -cw !.! 

Invoking debugger

You can assemble necessary invocation string on OFM command line or add external parameters inside the debugger (it is possible to change values of @ARGV array)
c:\cygwin\bin\perl -d !.! 

Invocation of Perl beautifier

Perl has one good beautifier (perltidy). Also Code2HTML  can convert a program source code to syntax highlighted HTML.

Invocation of OFM is simlar to examples above.

Invocation of Lint module and creation of XREF table

Although this is not well known, but Perl interpreter has lint module and can produce cross reference table of all variables used. Here is what authors of Programming Perl wrote about this rarely used capability:

18.6. Code Development Tools

The O module has many interesting Modi Operandi beyond feeding the exasperatingly experimental code generators. By providing relatively painless access to the Perl compiler's output, this module makes it easy to build other tools that need to know everything about a Perl program.

The B::Lint module is named after lint(1), the C program verifier. It inspects programs for questionable constructs that often trip up beginners but don't normally trigger warnings. Call the module directly:

perl -MO=Lint,all myprog
Only a few checks are currently defined, such as using an array in an implicit scalar context, relying on default variables, and accessing another package's (nominally private) identifiers that start with _. See B::Lint(3) for details.

The B::Xref module generates cross-reference listings of the declaration and use of all variables (both global and lexically scoped), subroutines, and formats in a program, broken down by file and subroutine. Call the module this way:

perl -MO=Xref myprog > myprof.pxref
For instance, here's a partial report:
Subroutine parse_argv
  Package (lexical)
    $on               i113, 114
    $opt              i113, 114
    %getopt_cfg       i107, 113
    @cfg_args         i112, 114, 116, 116
  Package Getopt::Long
    $ignorecase       101
    &GetOptions       &124
  Package main
    $Options          123, 124, 141, 150, 165, 169
    %$Options         141, 150, 165, 169
    &check_read       &167
    @ARGV             121, 157, 157, 162, 166, 166
This shows that the parse_argv subroutine had four lexical variables of its own; it also accessed global identifiers from both the main package and from Getopt::Long. The numbers are the lines where that item was used: a leading i indicates that the item was first introduced at the following line number, and a leading & means a subroutine was called there. Dereferences are listed separately, which is why both $Options and %$Options are shown.

The B::Deparse is a pretty printer that can demystify Perl code and help you understand what transformations the optimizer has taken with your code. For example, this shows what defaults Perl uses for various constructs:

% perl -MO=Deparse -ne 'for (1 .. 10) { print if -t }'
LINE: while (defined($_ = <ARGV>)) {
    foreach $_ (1 .. 10) {
        print $_ if -t STDIN;
    }
}
The -p switch adds parentheses so you can see Perl's idea of precedence:
% perl -MO=Deparse,-p -e 'print $a ** 3 + sqrt(2) / 10 ** -2 ** $c'
print((($a ** 3) + (1.4142135623731 / (10 ** (-(2 ** $c))))));
You can use -q to see what primitives interpolated strings are compiled into:
% perl -MO=Deparse,-q -e '"A $name and some @ARGV\n"'
'A ' . $name . ' and some ' . join($", @ARGV) . "\n";
And this shows how Perl really compiles a three-part for loop into a while loop:
% perl -MO=Deparse -e 'for ($i=0;$i<10;$i++) { $x++ }'
$i = 0;
while ($i < 10) {
    ++$x;
}
continue {
    ++$i
}
You could even call B::Deparse on a Perl bytecode file produced by perlcc -b, and have it decompile that binary file for you. Perl opcodes may be a tough read, but when necessary it can be helpful.

 

Tools that should be integrated in IDE

There are half dozen of key components of any IDE each of which exist as high quality independent component that can be integrated (with weaker or stronger level of integration, depending on the capabilities of particular IDE) into your own framework.

Beautifiers and Prettyprinters

Perl has one good beautifier (perltidy). The problem with writing a good Perl beautifier is the complexity of lexical structure of the language with such elements as qw, qq, etc. 

I wrote my own simple Perl pretty printer called neatperl for use with my custom OFM-based Perl IDE.

Perltidy is an OK choice as it is well debugged and has little chances to mangle your script:

Perltidy is a Perl script which indents and reformats Perl scripts to make them easier to read. If you write Perl scripts, or spend much time reading them, you will probably find it useful.

Here are a few examples of reformatted code snippets:

The formatting can be controlled with command line parameters. The default parameter settings approximately follow the suggestions in the Perl Style Guide.

Perltidy can also output html of both pod and source code. For example, the link below is an html version of the module Conf.pm from SpamAssassin.

Besides reformatting scripts, Perltidy can be a great help in tracking down errors with missing or extra braces, parentheses, and square brackets because it is very good at localizing errors.

Converters for HTML

Also Code2HTML  can convert Perl source code to syntax highlighted HTML. Some Perl editors has this capability too.

Perl Lint

Perl has a very useful but almost unknown and very rarely used by developers link module:

18.6. Code Development Tools

The O module has many interesting Modi Operandi beyond feeding the exasperatingly experimental code generators. By providing relatively painless access to the Perl compiler's output, this module makes it easy to build other tools that need to know everything about a Perl program.

The B::Lint module is named after lint(1), the C program verifier. It inspects programs for questionable constructs that often trip up beginners but don't normally trigger warnings. Call the module directly:

% perl -MO=Lint,all myprog
Only a few checks are currently defined, such as using an array in an implicit scalar context, relying on default variables, and accessing another package's (nominally private) identifiers that start with _. See B::Lint(3) for details.

Deparse module

The B::Deparse is a pretty printer that can demystify Perl code and help you understand what transformations the optimizer has taken with your code. For example, this shows what defaults Perl uses for various constructs:

% perl -MO=Deparse -ne 'for (1 .. 10) { print if -t }'
LINE: while (defined($_ = <ARGV>)) {
    foreach $_ (1 .. 10) {
        print $_ if -t STDIN;
    }
}
The -p switch adds parentheses so you can see Perl's idea of precedence:
% perl -MO=Deparse,-p -e 'print $a ** 3 + sqrt(2) / 10 ** -2 ** $c'
print((($a ** 3) + (1.4142135623731 / (10 ** (-(2 ** $c))))));
You can use -q to see what primitives interpolated strings are compiled into:
% perl -MO=Deparse,-q -e '"A $name and some @ARGV\n"'
'A ' . $name . ' and some ' . join($", @ARGV) . "\n";
And this shows how Perl really compiles a three-part for loop into a while loop:
% perl -MO=Deparse -e 'for ($i=0;$i<10;$i++) { $x++ }'
$i = 0;
while ($i < 10) {
    ++$x;
}
continue {
    ++$i
}
You could even call B::Deparse on a Perl bytecode file produced by perlcc -b, and have it decompile that binary file for you. Serialized Perl opcodes may be a tad tough to read, but strong encryption they are not.

Perl::Critic

From PerlCritic - Wikipedia, the free encyclopedia

Perl::Critic is a static code analysis system for the Perl programming language. Perl::Critic is available as a source-code distribution on CPAN. It comes with a commandline tool, perlcritic, which can check Perl source code files and report on the code quality therein. Perl::Critic has an extensible architecture that allows the programmer to choose from many "policies" which enforce different Perl programming styles and tastes. The default policy is largely based on the recommendations in the book Perl Best Practices by Damian Conway.

Perl::Critic is based on the PPI parsing library. For safety, PPI does not execute any code while parsing, unlike the Perl compiler, so it is a close approximation of the real parser rather than an exact representation.

Some new alternatives include Perl::Lint and B::Lint.

 

Documentation viewer

Typically documentation now is viewed via web using web browser. So there is not real need in separate component here for viewing standard Perl documentation. You can view it via IE of Firefox or whatever browser you prefer.

Perl has another type of documentation that resembles somewhat "literary programming" paradigm. It is called POD. You can incorporate POD into your script text and extract it using POD viewer. So POD viewer here is the just regular viewer and it can added to OFM as such. With editor it is just a special macro.


Top updates

Softpanorama Switchboard
Softpanorama Search



NEWS CONTENTS

Old News ;-)

EPIC - Eclipse Perl Integration

EPIC is an open source Perl IDE (including editor and debugger) based on the Eclipse platform, compatible with Windows, Linux and Mac OS X. Whether you are into CGI scripting or full-fledged Perl projects with hundreds of modules, EPIC is the most feature-rich and extensible free Perl IDE available today, thanks to a seamless integration with all the major features and GUI conventions of Eclipse.

Syntax highlighting
Configurable coloring of syntactic elements
On-the-fly syntax check
Syntax errors detected and explained as you type or upon saving a file
Content assist
Autocompletion for subroutine and variable names
Quick reference feature
Documentation tooltips for built-in Perl functions
Outline view
Displays used modules and subroutines contained in the edited file
Source formatter
Integrated perltidy and HTML export feature
Perldoc support
Integrated perldoc for quick acccess to documentation
Templating support
Create a library of code snippets to save typing
Persistent breakpoints
Breakpoints stay set between IDE restarts
Single Step/Step Into/Step Over
Tried and true execution control features
Global and local variables inspection
Displays contents of variables (PadWalker module required)
Expression evaluation
Execute user-defined expressions while debugger is paused
RegExp Plug-in
Multiline/ignorecase support

Subexpression highlighting

Single step for debugging

Perl::Critic integration
Helps keep your coding style nice and tidy
...and more!

Open Perl IDE download

Abandonware

SourceForge.net

Open Perl IDE is a visual, integrated development environment for writing and debugging Perl scripts with any standard Perl distribution under Windows 95/98/NT/2000.

Open Perl IDE Web Site

Open Perl IDE is an integrated development environment for writing and debugging Perl scripts with any standard perl distribution under Windows 95/98/NT/2000.

This software is written in Delphi 5 Object Pascal and Perl and it is OpenSource, distributed under Mozilla Public Licence 1.1 and hosted by SourceForge. Please visit our project page to get further information.

Now, take a look at some screenshots, read the User Manual to get a more detailed description of Open Perl IDE or download the latest release (Version 1.0).

The new release 1.0 is the first non-beta version of Open Perl IDE and fixes most of the bugs reported for previous releases. However, some of the changes are much more than simple bugfixes:

  • Better syntax coloring by using a new highlighter component.

  • Important debugger improvements, including better support for huge arrays.

  • Previous instance detection on program start.

  • Several minor HelpViewer and Configuration enhancements.


For any information, questions, remarks or bug reports, please send a message to Jürgen Güntherodt.

[Jul 16, 2012] What's the best Perl IDE

This discussion contain a lot of interesting tidbits. They are slightly outdated (written in 2007)
Sep 17, 2007 | PerlMonks

I wish vi fanbois and emacs die-hards stopped recommending them as Perl IDEs. They are editors, as much as you love them. They don't have debuggers, stack tracers, variable watching, breakpoints, regexp builders, or anything that makes up a real Perl IDE.

That said, Perl IDEs are listed at perlide.org.

There are two serious paid Perl IDEs:

The two serious free Perl IDEs are Padre and Eclipse + the EPIC plugin.

I compared Komodo vs. Eclipse and stuck with Komodo because of its remote debugging capabilities.

Padre is still immature but the good part is that you can improve it, since it's written in Perl, unlike EPIC (written in Java).

[Jan 19, 2011] The Perltidy Home Page

Perltidy is a Perl script which indents and reformats Perl scripts to make them easier to read. If you write Perl scripts, or spend much time reading them, you will probably find it useful.

Here are a few examples of reformatted code snippets:

The formatting can be controlled with command line parameters. The default parameter settings approximately follow the suggestions in the Perl Style Guide.

Perltidy can also output html of both pod and source code. For example, the link below is an html version of the module Conf.pm from SpamAssassin.

Besides reformatting scripts, Perltidy can be a great help in tracking down errors with missing or extra braces, parentheses, and square brackets because it is very good at localizing errors.

prettyprinter.de

This is a Web-based source code beautifier (source code formatter), similiar to indent. Please make a backup before you replace your code!

[Jan 19, 2011] pb

#!/usr/bin/perl

# 'pb' Perl Beautifier

# Written by P. Lutus Ashland, Oregon lutusp@arachnoid.com 5/20/96

# This script processes Perl scripts, cleans up and indents, like cb does for C

# Be careful with this script - it accepts wildcards and processes every text file
# that meets the wildcard criteria. This could be a catastrophe in the hands of the unwary.

$tabstring = "  "; # You may place any tab-stop characters you want here

if($ARGV[0] eq "") {
  print "usage: file1 file2 etc. or wildcards (replaces originals in place)\n";
}
else {
  foreach $filename (@ARGV) {
    if(-T $filename) {
      &process($filename);
    }
  }
}

sub process {
  $fn = $_[0];
  undef $/; # so we can grab the entire file at once
  undef @infa; # prevent left-overs
  print STDERR "$fn";
  open (INFILE,$fn);
  @infa = split(/\n/,<INFILE>);
  close INFILE;
  
  $/ = "\n"; # restore default
  
  open (OUTFILE,">$fn");
  $tabtotal = 0;
  for (@infa) {
    
    s/^\s*(.*?)\s*$/$1/; # strip leading and trailing spaces
    
    $a = $_; # copy original string
    $q = $a; # i plan to modify this copy for testing
    $q =~ s/\\\#//g; # remove escaped comment tokens
    $q =~ s/\#.*?$//g; # remove Perl-style comments
    $q =~ s{/\*.*?\*/} []gsx; # remove C-style comments
    $q =~ s/\\\{//g; # remove escaped left  braces
    $q =~ s/\\\}//g; # remove escaped right braces
    $q =~ s/\\\(//g; # remove escaped left  parentheses
    $q =~ s/\\\)//g; # remove escaped right parentheses
    
    $q =~ s/\'.*?\'//g; # remove single-quoted lines
    
# now the remaining braces/parentheses should be structural
    
    $delta = -($q =~ s/\}/\}/g); # subtract closing braces
    $delta += ($q =~ s/\{/\{/g); # add opening braces
    
    $delta -= ($q =~ s/\)/\)/g); # subtract closing parens
    $delta += ($q =~ s/\(/\(/g); # add opening parens
    
    $tabtotal += ($delta < 0)?$delta:0; # subtract closing braces/parentheses
    
    $i = ($tabtotal > 0)?$tabtotal:0; # create tab index
    
    $tabtotal += ($delta>0)?$delta:0; # add opening braces/parentheses for next print
    
    if(substr($a,0,1) ne "#") { # don't tab comments
      print OUTFILE $tabstring x $i; # "tab" out to position
    }
    
    print OUTFILE "$a\n"; # print original line
  } # -- for (@infa)
  
  close OUTFILE;
  
  if($tabtotal != 0) {
    print STDERR " Indentation error: $tabtotal\n";
  }
  else {
    print STDERR "\n";
  }
} # sub process

Beautifier freshmeat.net

Beautifier (previously known as PSH, the PHP Syntax Highlighter) highlights and indents source code using highlight configuration files which are similar to Ultraedit highlighting files. It supports C, C#, Java, Perl, PHP, Pascal, Lisp, Mumps, Eiffel, Euphoria, and x86 Assembler, amongst others. It handles line/block comments, keyword highlighting, correct indentation, string highlighting, language contexts (allowing embedded languages), and selection highlighting. It is available in PHP and Perl versions.

Scintilla and SciTE

SciTE is a SCIntilla based Text Editor. Originally built to demonstrate Scintilla, it has grown to be a generally useful editor with facilities for building and running programs. It is best used for jobs with simple configurations - I use it for building test and demonstration programs as well as SciTE and Scintilla, themselves.

SciTE is currently available for Intel Win32 and Linux compatible operating syshttp://www.scintilla.org/SciTEImage.html">Here is a screenshot of SciTE.

On Windows, there is a companion application Filerx which provides project management and macro features to SciTE.

You can download Scintilla and SciTE.

There are some extra configuration files that can enhance SciTE for various languages and APIs.

The scite-interest mailing list has moved from lyra.org to Google Groups. Questions and comments about SciTE should be directed to the scite-interest mailing list, which is for discussion of SciTE and related projects, their bugs and future features. This is a low traffic list, averaging less than 50 messages per week. To avoid spam, only list members can write to the list. New versions of SciTE are announced on scite-interest and may also be received by SourceForge members by clicking on the Monitor column icon for "scite" on the downloads page. Messages sent to my personal email address that could have been sent to the list may receive no response.
There is a Scintilla project page

Wat's the best free Perl IDE?

why don't you try Eclipse with Epic (an eclipse perl plug in) ;)

Check out Padre, http://padre.perlide.org/

Ulrich Habel wroteon June 17, 2009 at 5:05pm

Personally I like SciTE which is more an editor which is customizable. You can have your own menu entries which might use tools or even Perl scripts in the background. It's very small and very fast.

In order to fulfill the request for the IDE I would suggest looking into Padre. It has some great features like lexical replacement with refactoring, it reads your code and assists you. You'll end up installing full CPAN if you build it on your own.

Padre Perl Application Development and Refactoring Environment

Homepage of Crimson Editor - Free Text Editor, Html Editor, Programmers Editor for Windows

Syntax Highlighting for HTML, C/C++, Perl, Java, Matlab and LaTeX. Also, it can be extended for other programming languages based on custom syntax files.

Perl Code Editor A superior notepad editor for Windows with syntax coloring and line numbers

A Perl code editor for Windows. Allows Perl programmers to develop and edit scripts with a more advanced editor compared to the standard notepad that comes with Windows. Features include: Syntax Coloring, Bookmarks, Auto Indenting, Line Ending Conversion (Unix to Windows), Drag and Drop Support, Goto Line by Line Number, and Handles .pl and .cgi files. Also includes a context/right click menu for fast access to the most commonly used features.

SannySoft Perl Editor

Perl Editor 2005 is a feature-packed Integrated Development Environment for Perl programmers. Why do Perl coders need it? Here is an analogy - you probably have both Notepad and MS Word on your PC. Both are text-editors or word processors. Which tool do you think professional writers prefer?

... Since the program was created by an experienced team of Perl programmers, Perl Editor has every feature Perl coder could possible need and does not have any extraneous options that would make the program complicated, hard to learn or difficult to use.
http://www.perleditor.net/download/SannySoftPerlEditor.zip - 3Mb - Download - Screenshot

DzSoft Perl Editor

DzSoft Perl Editor is a tool for writing, editing, and debugging Perl/CGI scripts. It has a comfortable and intuitive interface both for beginners and advanced programmers. DzSoft Perl Editor is deceptively simple, but it is really a very powerful tool. ... With DzSoft Perl Editor you can run a script and see the result immediately in just one click (you dont even have to run a web server to test a CGI script in the browser)! ... Features Code Explorer, very comfortable editor with syntax highlighting, syntax check, easy debugging of command line and CGI scripts with breakpoints and...
http://www.dzsoft.com/download/dzperl57.exe - 2Mb - Download - Screenshot

Top Perl Studio

Top Perl Studio is an Integrated Development Environment for Perl, providing comprehensive and easy-to-use solution for editing, testing and deploying CGI/Perl based web applications. Top Perl Studio includes a built-in HTTP server which directly runs CGI/Perl code and an internal web browser... Top Perl Studio's powerful code editor supports configurable syntax highlighting for Perl, HTML, XML, SQL... ... Other major features are: built-in FTP client, file/server explorer, syntax checking for Perl code, visual file comparison utility, code snippets for CSS and HTML tags, automatic...
http://www.top-systems.net/Top-Perl-Studio/tperlstudio-trial-en.zip - 2Mb - Download - Screenshot

Perl Express

Abandonware

A free integrated development environment (IDE) for Perl with multiple tools for writing and debugging your scripts. It features multiple CGI scripts for editing, running, and debugging; multiple input files; full server simulation; queries created from an internal Web browser or query editor;... It has a customizable code editor with syntax highlighting, unlimited text size, printing, line numbering, bookmarks, column selection, a search-and-replace engine, multilevel undo/redo operations, and so on.
http://www.perl-express.com/PeSetup25.exe - 3Mb - Download - Screenshot

Perl Builder

Perl Builder is a complete integrated development environment (IDE) for Perl. Key features include a visual editor/debugger that is similar to products such as Visual Basic and Delphi. The CGI Wizard component lets both novices and experienced programmers create powerful scripts visually,... The Perl Builder IDE includes all the features you expect in a professional development tool, including color syntax highlighting, automatic indentation, a full-featured debugger with mouseover variable inspection, single step, watches, and data structure dump.

[Mar 25, 2006] DZsoft Perl Editor Version 5.7.0.7. Shareware $49.

DzSoft Perl Editor has debugging features, a very comfortable editor with syntax highlighting, a syntax check feature that finds errors in your script, and many other features for easy and comfortable Perl development.

[Aug 25, 2005] Perl.com Perl Needs Better Tools By Matisse Enzer

Perl is in danger of becoming a fading language--new programmers are learning Java and Python in college, and companies like Google hardly use Perl at all. If you are afraid that Perl may be in danger of becoming irrelevant for medium-to-large projects, then read on.

The Scary Part

I have discussed the future of Perl with managers from companies that currently use it and find that they worry about the future of Perl. One company I spoke with here in San Francisco is rewriting their core application in Java. Another company worries they will not be able to find new Perl programmers down the road. Yet another uses Perl for major projects, but suffers from difficulty in refactoring their extensive code base.

There are many reasons why companies care about the future of Perl. I offer a part of a solution: better tools for Perl can be a major part of keeping Perl relevant and effective as the primary language for medium and large projects.

Related Reading

Perl Best Practices
By Damian Conway

Table of Contents
Index
Sample Chapter

When measuring the effectiveness of a development environment (people, language, tools, processes, etc.), a key measure is how expensive and painful it is to make changes to existing code. Once a project or system has grown to thousands of lines of code in dozens (or hundreds) of modules, the cost of making changes can escalate to the point where the team is afraid to make any significant change. Excellent tools are one of the ways to avoid this unhappy situation, or at least reduce its impact. Other factors are excellent processes and, of course, excellent people.

21st-Century Integrated Development Environments for Perl

I propose that more, high-quality development tools will help keep Perl relevant and alive in medium and large project environments. My focus in this article is on IDEs, or Integrated Development Environments, and primarily those with a graphical interface.

An IDE is an integrated set of tools for programming, combining a source code editor with a variety of other tools into a single package. Common features of modern IDEs include refactoring support, version control, real-time syntax checking, and auto-completion of code while typing.

I want to make it clear right at the outset that a team of highly skilled Perl programmers, using only tools that have been around for years (such as emacs, vi, cvs, and make) can and do build large, sophisticated, and successful projects. I am not worried about those programmers. I am worried about the larger population of programmers with one to five years of experience, and those who have not yet begun to program: the next generation of Perl programmers.

Great tools will not make a bad programmer into a good programmer, but they will certainly make a good programmer better. Unfortunately, the tools for Perl are years behind what is available for other languages, particularly Java.

One powerful example is the lack of graphical IDEs for Perl with excellent support for refactoring. Several IDEs for Java have extensive refactoring support. Only one for Perl, the EPIC plugin for Eclipse, supports even a single refactoring action.

For an example of how good IDEs have inspired at least one Perl developer, see Adam Kennedy's Perl.com article on his new PPI module and Scott Sotka's Devel::Refactor module (used in EPIC).

I acknowledge that a graphical IDE is not the be-all of good tools. Just as some writers reject word processors in favor of typewriters or hand-written manuscripts, some programmers reject graphical IDEs and would refuse a job that required them to use one. Not everyone has (nor should have) the same tool set, and there are things a pencil can do that vi and emacs will never do. That said, IDEs have wide use in businesses doing larger projects, and for many programmers and teams they provide major increases in productivity.

Another important point is that while this article discusses over a dozen specific tools or features, having all the tools in a single package produces the biggest value. An IDE that provides all of these features in a single package that people can easily install, easily extend, and easily maintain across an entire development team has far more value than the sum of its parts.

There is a big win when the features provided by an IDE immediately upon installation include all or almost all of the tools and features discussed here and where the features "know" about each other. For example, it is good if you enter the name of a non-existent subroutine and the real-time syntax checker catches this. It is much better if the code-assist feature then pops up a context menu offering to create a stub for the subroutine or to correct the name to that of an existing similar subroutine or method from another class that is available to the current file. (This is standard behavior for some Java IDEs.)

What Would a 21st-Century Perl Tool Set Contain?

Perl needs a few great IDEs--not just one, but more than one so that people have a diverse set to choose from. Perl deserves and needs a few great IDEs that lead the pack and set the standard for IDEs in other languages.

I am well aware that the dynamic nature of Perl makes it harder to have a program that can read and understand a Perl program, especially a large and complex one, but the difficulty in comprehending a Perl program makes the value of such a tool all the greater, and I have faith that the Perl community can overcome some of the built-in challenges of Perl. Indeed, it is among the greatest strengths of Perl that Perl users can adapt the language to their needs.

A great Perl IDE will contain at least the following, plus other features I haven't thought of. (And, of course, there must be many of those!)

Most of the screen shot examples in this article use the EPIC Perl IDE. At present, it has the largest amount of the features on my list (although it certainly doesn't have all of them).

Syntax-Coloring Text Editor

Most of you have probably seen this. It is available under vim, emacs, BBEdit, and TextPad. Just about every decent text editor will colorize source code so that keywords, operators, variables, etc., each have their own color, making it easier to spot syntax errors such as forgetting to close a quote pair.

Real-Time Syntax Checking

real-time syntax check example
Figure 1. Real-time syntax checking

The IDE in Figure 1 shows that line 4 has an error because of the missing ) and that line 5 has an error because there is no declaration of $naame (and use strict is in effect).

A key point here is that the IDE shows these errors right away, before you save and compile the code. (In this example, the EPIC IDE lets you specify how often to run the syntax check, from 0.01 to 10.00 seconds of idle time, or only on demand.)

As nice as this is, it would be even better if the IDE also offered ways to fix the problem, for example, offering to change $naame to $name. Figure 2 shows an IDE that does exactly that; unfortunately, for Java, not Perl.

syntax help from the IDE
Figure 2. Syntax help from the IDE

It would be great if Perl IDEs offered this kind of help.

Version Control Integration

All non-insane large projects use version control software. The most common version control software systems are probably CVS, Perforce, Subversion, and Visual SourceSafe. Figure 3 shows an IDE comparing the local version of a file to an older version from the CVS repository.

Figure 3
Figure 3. Comparing a local file to an older version in CVS--click image for full-size screen shot

CVS integration is available in many modern code editors, including emacs, vim, and BBEdit, as well as graphical IDEs such as Eclipse and Komodo Pro. Subversion integration is available as a plugin for Eclipse; Komodo Pro supports Perforce and Subversion.

A Code-Assist Editor

Suppose that you have just typed in an object reference and want to call a method on the object, but you are not sure what the method name is. Wouldn't it be nice if the editor popped up a menu listing all of the methods available for that object? It might look something like Figure 4.

automatic code completion
Figure 4. Automatic code completion

In this example, the IDE is able to figure out which class the object $q is an instance of and lists the names of the available methods. If you type a p, then the list shows only the method names beginning with p. If you type pa, then the list shows only the param() and parse_params() methods.

Excellent Refactoring Support

The easier it is to do refactoring, the more often people will do it. The following list contains the most common refactorings. Your personal list will probably be a little different. All of these are things you can do "manually," but the idea is to make them into one or two-click operations so that you will do them much more often. (For a extensive list of refactoring operations, see Martin Fowler's alphabetical list of refactorings.)

Extract Subroutine/Method

The IDE should create a new subroutine using the selected code and replace the selected code with a call to the new subroutine, with the proper parameters. Here's an example of using the Extract Subroutine refactoring from Eclipse/EPIC (which uses the Devel::Refactor module).

First, you select a chunk of code to turn into a new subroutine, and then select Extract Subroutine from a context menu. You then get the a dialog box asking for the name of the new subroutine (shown in Figure 5).

code before Extract
Subroutine refactoring
Figure 5. Code before Extract Subroutine refactoring

The IDE replaces the selected code with a call to the new subroutine, making reasonable guesses about the parameters and return values (Figure 6). You may need to clean up the result manually.

code after Extract
Subroutine refactoring
Figure 6. Code after Extract Subroutine

Figure 7 shows the new subroutine created by the IDE. In this case, it needs no changes, but sometimes you will need to adjust the parameters and/or return value(s).

the new subroutine
created by Extract Subroutine
Figure 7. The new subroutine created by Extract Subroutine

Ideally, the editor should prompt you to replace similar chunks of code with calls to the new subroutine.

Rename Subroutine/Method

The IDE should find all the calls to the subroutine throughout your project and offer to change them for you. You should be able to see a preview of all of the places a change could occur, and to accept or reject each one on a case-by-case basis. The action should be undoable.

Rename Variable

Like Rename Subroutine, this feature should find all occurrences throughout the project and offer to make the changes for you.

Change Subroutine/Method Signature

The IDE should be able to make reasonable guesses about whether each subroutine or method call is supplying the proper parameters. Partly this is to enable the real-time syntax checking mentioned above, and partly this is to enable you to select a subroutine declaration and tell the IDE you want to refactor it by adding or removing a parameter. The IDE should then prompt you for the change(s) you want to make, do its best to find all of the existing calls to the subroutine, and offer to correct the subroutine calls to supply the new parameters.

Obviously, this is an especially tricky thing to do in Perl, where subroutines fish their parameters out of @_. So the IDE would have to look carefully at how the code uses shift, @_, and $_[] in order to have a reasonable guess about the parameters the subroutine is expecting. In many common cases, though, a Perl IDE could make a reasonable guess about the parameters, such as in the following two examples, so that if you added or removed one, it could immediately prompt you about making corrections throughout the project:

sub doSomething {
    my $gender = shift;
    my $age    = shift;
    # Not too terribly hard to guess that $gender and $age are params
}

sub anotherThing {
    my ($speed,$direction) = @_;
    # No magic needed to guess $speed and $direction are params.
}
Move Subroutine/Method

This refactoring operation should give you a list or dialog box to choose the destination file in your project. The IDE should allow you to preview all of the changes that it would make to accomplish the move, which will include updating a call to the subroutine/method to use the proper class. At a minimum, the IDE should show you or list all of the calls to the subroutine so you can make the appropriate changes yourself. Ideally, the IDE should make a guess about possible destinations; for example, if $self is a parameter to the method being moved, then the IDE might try assuming the method is an object (instance) method and initially only list destination classes that inherit from the source class, or from which the source class inherits.

Change a Package Name

As with Rename Subroutine and Rename Variable, when changing a package name, the IDE should offer to update all existing references throughout your project.

Tree View and Navigation of Source Files and Resources

Another useful feature of good IDEs is being able to view all of the code for a project, or multiple projects, in a tree format, where you can "fold" and "unfold" the contents of folders. All of the modern graphical IDEs support this, even with multiple projects in different languages.

Being able to view your project in this manner gives you both a high-level overview and the ability to drill down into specific files, and to mix levels of detail by having some folders show their contents and some not.

For example, Figure 8 shows a partial screen shot from ActiveState's Komodo IDE.

tree view of code in Komodo
Figure 8. Tree view of code in Komodo

Support for Creating and Running Unit Tests

Anyone who has installed Perl modules from CPAN has seen unit tests--these are the various, often copious, tests that run when you execute the make test part of the installation process. The vast majority of CPAN modules include a suite of tests, often using the Test::Harness and/or Test::More modules. A good IDE will make it very easy to both create and run unit tests as you develop your project.

The most basic form of support for unit tests in an IDE is simply to make it easy to execute arbitrary scripts from within the IDE. Create a test.pl for your project and keep adding tests to it or to a t/ subdirectory as you develop, and keep running the script as you make changes. All modern IDEs provide at least this minimal capability.

A more sophisticated level of support for unit tests might resemble the Java IDE feature for tests written in JUnit, where you can select an existing class file (a .pm file in Perl) and ask the IDE to create a set of stub tests for every subroutine in the file. (See JUnit and the Perl module Test::Unit for more on unit tests.) Furthermore, the IDE should support running a set of tests and giving simple visual feedback on what passed/failed. The standard approach in the JUnit world is to show either a "green bar" (all passed) or "red bar" (something failed) and then allow you to see details on failures. Other nice-to-have features include calculating code-coverage, providing statistical summaries of tests, etc.

Figure 9 shows a successful run of a Java test suite with Eclipse.

JUnit test run, success
Figure 9. A successful JUnit test run

Figure 10 shows the same test run, this time with a failure.

JUnit test run, with a failure.
Figure 10. A JUnit test run with a failure

A stack trace of the failure message appears in another part of the window (cropped out here to save space). If you double-click on the test that failed (testInflate), the IDE will open the file (BalloonTest, in this case) and navigate to the test function.

The central idea is that the IDE should make it as painless as possible to add and modify and run tests, so you will do more of it during development.

Language-Specific Help

This is a fairly straightforward idea--the IDE should be able to find and display the appropriate documentation for any keyword in your code, so if you highlight push and ask for help, you should see the push entry from the Perl documentation. If you highlight a method or subroutine or other symbol name from an imported module, the IDE should display the module's documentation for the selected item. Of course, this requires that the documentation be available in a consistent, machine-readable form, which is only sometimes true.

Debugger with Real-Time Display of Results

All modern IDEs offer support for running your code under a debugger, usually with visual display of what's going on, including the state of variables. The Komodo IDE supports debugging Perl that is running either locally or remotely.

Typical support for debugging in an IDE includes the ability to set breakpoints, monitor the state of variables, etc. Basically, the IDE should provide support for all of the features of the debugger itself. Graphical IDEs should provide a visual display of what is going on.

Automatic Code Reformatting

This means automatically or on-demand re-indenting and other reformatting of code. For example, when you cut and paste a chunk of code, the IDE should support reformatting the chunk to match the indentation of its new location. If you change the number of spaces or tabs for each level of indentation, or your convention for the placement of curly braces, then the IDE should support adjusting an entire file or all files in your project.

Seamless Handling of Multiple Languages

Many large software projects involve multiple languages. This is almost universally true in the case of web applications, where the user interface typically uses HTML, CSS, and JavaScript, and the back end uses one or more of Perl, PHP, Java, Python, Ruby, etc. It is very helpful to have development tools that seamlessly integrate work done in all of the languages. This is becoming quite common. For example, both Komodo and Eclipse support multiple languages.

Automated Building and Testing

This feature can be very basic by making it easy to run an arbitrary script from within the IDE and to see its output. This could be as simple as having the IDE configured to have a one-click way of running the traditional Perl module build-and-test commands:

$ perl Makefile.PL
$ make
$ make test

A more advanced version of this feature might involve having the IDE create stub code to test all of the subroutines in an existing file, or to run all of the scripts in a specified directory under Test::Harness, or to run a set of tests using Test::Unit::TestRunner or Test::Unit::TkTestRunner. (The latter provides a GUI testing framework.)

Conclusion and Recommendations

While there are many tools for helping Perl development, the current state of the Perl toolbox is still years behind those of other languages--perhaps three to five years behind, when compared to Java tools. While there are several tools for Java that have all the features described above, virtually none for Perl have all of them. On the other hand, things are looking up; they are better now than a year ago. It's possible to close that gap in a year or two.

A couple of obvious areas where improvements could be somewhat easy are adding more features to EPIC and Komodo. EPIC is open source, so there is potentially a wider pool of talent that could contribute. On the other hand, Komodo has a company with money behind it, so people actually get paid to improve it. Hopefully both tools will get better with time.

Another interesting possibility is the development of new IDEs or adding to existing ones by using Adam Kennedy's PPI module, which provides the ability to parse Perl documents into a reasonable abstract syntax tree and to manipulate the elements and re-compose the document. There is a new Perl editor project, VIP, that is in the design stages and is intended to be "pluggable" and to have special features to support pair programming.

Finally, I've gathered a couple of lists of links for related material. The first list below consist of IDEs and graphical editors for Perl, and the second list consists of various related articles and websites. I hope this is all inspirational and helpful.

[Jul 29, 2005] Open Perl IDE is an integrated development environment for writing and debugging Perl scripts with any standard perl distribution under Windows 95/98/NT/2000.

This software is written in Delphi 5 Object Pascal and Perl and it is OpenSource, distributed under Mozilla Public Licence 1.1 and hosted by SourceForge.

Please visit our project page to get further information.

Now, take a look at some screenshots, read the User Manual to get a more detailed description of Open Perl IDE or download the latest release (Version 1.0).

The new release 1.0 is the first non-beta version of Open Perl IDE and fixes most of the bugs reported for previous releases. However, some of the changes are much more than simple bugfixes:


For any information, questions, remarks or bug reports, please send a message to Jürgen Güntherodt.

[Jan 2, 2005] ExecPerl - Utilities for executing perl scripts vim online

Provides the following commands:

:ExecPerl script_name
This will execute script_name using the perl
interpreter.

:ExecPerlMore
This will execute script_name using the perl
interpreter. If the output would scroll past the end
of the screen, execution pauses and waits for a
keystroke before continuing.

:ExecPerlDump
This will ask you for an output file and then
execute script_name using the perl interpreter. The
output from the script is dumped to the file that you
entered when you were prompted. You may press enter
instead of entering a file name to accept the default
filename.

Also, The following keys are mapped by default. You'll have to
comment them if you don't want this behavior:

<F5>: ExecPerl the current file being edited
<C-F5>: ExecPerlMore the current file being edited
<S-F5>: ExecPerlDump the current file being edited

[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.

Which Open Source Wiki Works For You

ONLamp.com

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

Perl Development Tools

What's the best Perl IDE

Xref Tools

The B::Xref module generates cross-reference listings of the declaration and use of all variables (both global and lexically scoped), subroutines, and formats in a program, broken down by file and subroutine. Call the module this way:

% perl -MO=Xref myprog > myprof.pxref

For instance, here's a partial report:

Subroutine parse_argv
  Package (lexical)
    $on               i113, 114
    $opt              i113, 114
    %getopt_cfg       i107, 113
    @cfg_args         i112, 114, 116, 116
  Package Getopt::Long
    $ignorecase       101
    &GetOptions       &124
  Package main
    $Options          123, 124, 141, 150, 165, 169
    %$Options         141, 150, 165, 169
    &check_read       &167
    @ARGV             121, 157, 157, 162, 166, 166

This shows that the parse_argv subroutine had four lexical variables of its own; it also accessed global identifiers from both the main package and from Getopt::Long. The numbers are the lines where that item was used: a leading i indicates that the item was first introduced at the following line number, and a leading & means a subroutine was called there. Dereferences are listed separately, which is why both $Options and %$Options are shown.

[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&

HTML converters

GNU Source-highlight - GNU Project - Free Software Foundation (FSF)  v1.6 by Lorenzo Bettini

This program, given a source file, produces a document with syntax highlighting.

At the moment this package can handle

as source languages, and

as output format.

NOTICE: now the name of the program is source-highlight: there are no two separate programs, namely java2html and cpp2html, anymore.  However there are two shell scripts with the same name in order to facilitate the migration (however their use is not advised).

GNU Source-highlight is free software. Please see the file COPYING for details. For documentation, please read this file.

GNU Source-highlight is a GNU program and its main home page is at GNU site:
http://www.gnu.org/software/src-highlite/source-highlight.html

You can download it from GNU's ftp site:
ftp://ftp.gnu.org/gnu/source-highlight/ or from one of its mirrors (see http://www.gnu.org/prep/ftp.html).

I do not distribute Windows binaries anymore; since, they can be easily built by using Cygnus C/C++ compiler, available at http://www.cygwin.com/. However, if you don't feel like downloading such compiler, you can request such binaries directly to me, by e-mail (bettini@gnu.org) and I can send them to you.
An MS-Windows port of Source-highlight is available from http://gnuwin32.sourceforge.net/.

You may also want to check the md5sum of the archives, which are also digitally signed by me (Lorenzo Bettini) with GNU gpg (http://www.gnupg.org). My GPG public key can be found at my home page (see at the end of this doc).

You can also get the patches, if they are available for a particular release (see below for patching from a previous version).

code2html

code2html by Peter Palfrader (Weasel) is a perlscript which converts a program source code to syntax highlighted HTML. It may be called from the command line or as a CGI script. It can also handle include commands in HTML files. Currently supports: Ada 95, C, C++, HTML, Java, JavaScript, Makefile, Pascal, Perl, SQL, AWK, M4, and Groff.

Homepage: http://www.palfrader.org/code2html

Freshmeat page: http://freshmeat.net/projects/code2html/

code2html is a perlscript which converts a program source code to syntax highlighted HTML. It may be called from the command line or as a CGI script. It can also handle include commands in HTML files. It really should be rewitten eventually since the code is so ugly.

License: MIT

This project has the following developers:

Download: http://www.giga.or.at/~weasel/pub/code2html/latest/ (1637 hits)
Alternate Download: http://www.cosy.sbg.ac.at/~ppalfrad/code2html/code2html.pl.gz (193 hits)
Homepage: http://www.cosy.sbg.ac.at/~ppalfrad/code2html/ (2653 hits)
Changelog: http://www.cosy.sbg.ac.at/~ppalfrad/code2html/history.html (97 hits)

 

Editors

VIM has (limited) support of Perl. See Softpanorama VI Editor Links

***** DzSoft Perl Editor 3.1 Very decent shareware editor with elements of Integrated environment. Contains built-in beautifier ! by Sergey Dzyubenko, Alexander Dzyubenko, DzSoft Ltd.

Perl Scripting Tool PRO Perl Made Easy Win32 editor.

NOTE: This is beta software. If you are not entirely comfortable using beta software, DO NOT install this version on your PC. We strongly recommend that BEFORE you install this software, you  make a backup copy of your existing PST folder and put that copy in a separate area.  Do not be alarmed if there is a big jump in beta build numbers; gaps exists because we create frequent internal builds. This is one of a series of beta releases of Perl Scripting Tool 2.00. As with any beta software, some features may not be fully implemented. If you find any problems with this software, please send us a bug report to: bugs@perlscriptingtool.com .

Perl Editors

ped A text editor with an emacs/vi-like user interface written in perl.[July 17, 1999]
Jul 08th 1999, 21:24 stable: none - devel: 0.1.2 license: Artistic

TkFileman Home Page

Perl::Tk

ptkpad.0.6.5.tar.gz
    This is an implementation of my Tk NotePad only it is done in Perl::Tk. The implementation is progressing quite fast and most of the features have been implemented. Currently the only features that have not been implemented are some keystroke bindings.
    Unfortunately there are a few bugs and is considered a beta release now, so please do not complain about bugs> I will welcome bug fixes. It originaly started out as a line by line conversion, but as I learn more about perl I am starting to optimize as well but this is a low priority.
   Some features that have been added in addition to what is in my original TkNotePad are the New Window Menu item, as well as a line and column indicator to tell the position of the cursor, and a goto line. I have also added an Options menu for changing a few things like the fonts. Many more features are planned. screenshot

PurePerl.org

EDITOR COST REVIEWS From PBML Posters
Perl Code Editor
from PerlVision
Free After Wordpad, this was my first Perl editor.  Syntax highlighting and line numbering is definitely a step up.
Favorite feature: line numbering.
Submitted by: Bompa
[read more reviews]
Open Perl IDE
by Jürgen Güntherodt
Free A big step up, yet still light on your cpu.  This is the one I use now because it's free and runs nicely even on my 122Mhz laptop.
Favorite feature:  A "run" button that runs the script and shows errors in a box at the bottom of the screen, this saves a bunch of testing time.  
Submitted by: Bompa
 
UltraEdit
IDM Computer Solutions, Inc
$35 Full featured, tons of options, settings, and features.
Favorite feature:  being able to "'comment out" whatever code I highlight with just one click, (and the reverse), great for troubleshooting.  I loved it and might still cough up the 35 bucks.
Submitted by: Bompa
OptiPerl
Xarka Software
$59 Full featured, tons of options, settings, and features, but more money than I want to spend at this time.
Submitted by: Bompa
 
Perl Builder 2.0
from Solutionsoft
$149 Submit a review.
visiPerl+
from Softpile
$59 Submit a review.
Komodo
from ActiveState
$295 Submit a review.
DzSoft Perl Editor
by DzSoft
$59 Like OptiPerl, full featured, tons of options, settings, and features, but more money than I want to spend at this time.
Submitted by: Bompa
 
EditPlus
by ES Computing
$30 Submit a review.

SciTE
Free source project.  
Project Admin:Neil Hodgson
Free Syntax highlighting for many languages, output pane, C-like macros (via FilerX), quick, small and mighty :-)
Submitted by: Jenda
 
VIM
Bram Moolenaar
Free Vi and emacs, the great unix editor debate. Personally I like vim, it's quick, works great over slow links and has more features than you can shake a stick at. Once you've grokked enough of the commands to make this little baby run you'll never want to go back. mouse? mouse? i don't want no steeenking mouse. You windows types can even join in the fun too.
Submitted by: Daniel Gardner
 

Networking

[Oct. 07, 2000] A special module IPC-Run by Barrie Slaymaker(barries@slaysys.com). After a user's spun up on bash/ksh, it provides useful piping constructs, subprocesses, and either expect-like or event loop oriented I/O capabilities.

www.perl.com Perl Reference/Networking

www.perl.com - You want to find the IP address of a host or turn an IP address into a name. Recipe of the Day

[Feb 20, 2000] pftp pFtp is a ftp client written in perl. It uses the Perl/Tk and Libnet libraries, both available from the CPAN FTP site. Download: pFtp 0.05

[Jan 28, 2000] DDJ EXAMINING PERLDAP  by Troy Neeriemer

Netscape's PerLDAP is an important tool for both programmers and administrators because it provides a mechanism for accessing directory information from Perl. Troy presents a high-level overview of PerLDAP, along with details of how you can use it. Additional resources include perldap.txt (listings) and perldap.zip (source code).


File managers

Paw (Perl ASCII Widgets) is a widgetset for generating a GUI on ASCII based terminals. It contains button, radiobutton, label, line, listbox, text_entry, pull-down-menu, filedialog, popup-box and more. Examples are included. This
software requires Perl::Curses.

[Apr 18, 2001] Drall -- Stable version 1.4.0.0. Much better that it was and now supports authentication using the same author's Averist module. Written in Perl (GNU license) Screenshots:

Here is the quote from the author page:

If you like Drall, please express your satisfaction with a donation: send me what you feel Drall has been worth to you. If you are glad that I developed Drall and distribute it as free software, rather than following the obstructive and antisocial practices typical of software developers, reward me. If you would like me to develop more free software, contribute.


Scripts Archives

US Mirrors Europe Mirrors
CPAN [Texas] CPAN [funet.fi]
CPAN [California] cdrom.com CPAN [ruhr-uni-bochum.de]
CPAN [New York] CPAN [pasteur.fr]
CPAN [Massachusetts] CPAN [ruu.nl]
  CPAN [sunet.se]
  CPAN [sunsite.auc.dk]