Sign In/My Account | View Cart  
advertisement


Listen Print

Visual Perl
by Eric Promislow | Pages: 1, 2

Getting the Job Done with Visual Perl

.NET aside, we worked hard to make Visual Perl an attractive alternative to emacs, vim and other editors favored by Perl programmers. Visual Studio .NET provides an editing environment familiar to developers who have always worked in Windows. But many Perl programmers cut their hash variables on emacs and vi, and are wary of giving up the powerful functionality of those editors.

However, implementing "vi" and "emacs" keystroke bindings wasn't the way to go. "Ctrl-X" has a long-established meaning in the GUI world, and we weren't about to let developers accidentally delete a chunk of selected text when they meant to start a multi-keystroke command.

So, while we couldn't preserve the keystrokes, we could go some way toward preserving the functionality. Visual Perl features:

  • configurable auto-indenting that provides the ability to set the level of indent, specify whether to insert spaces or tabs, and whether to auto-indent based on nesting constructs
  • auto-indenting based on the Camel book style, so it's sensitive to the location of enclosing braces and parentheses
  • the ability to show matching bracketing characters
  • keyboard shortcuts for moving to matching brackets, or selecting a block within the matching brackets
  • keyboard shortcuts for commenting and un-commenting blocks of selected text
  • the ability to collapse and expand blocks of code with a single mouse click
  • incremental searching, both forward and backward (although we hope to extend this functionality with incremental regular expression searches)

Visual Perl's colorizer is aware of some of Perl's more arcane constructs, including here-documents (stacked or plain), regex substitutions with different delimiters on the pattern and replacement, and ?-delimited regular expressions. And Visual Studio .NET's Options dialog lets you assign whatever color combination you want to each style.

Other features include the class browser, which is used to quickly navigate to the functions in the files loaded in a project. Integrated context-sensitive help provides quick information on Perl keywords. You can right click on a "use" or "require" statement, and view help for the imported module within the Visual Studio .NET environment. The debugger supports debugging of remote Perl programs, not just the program loaded in the IDE.

Visual Perl uses the Visual Studio .NET code completion framework to help walk the user through "::"-separated names when importing modules. It recognizes when an instance of a package is bound to a variable, and presents available methods when "->" is typed after the variable. Visual Perl isn't doing anything fancy here; it's simply assuming that good developers try to maintain a many-to-one relationship between their variable names and the types the variables are labels for. So when Visual Perl sees that a variable called "$ua" is an instance of LWP::UserAgent, it assumes that other instances of that variable are as well. This definitely isn't thorough, and assumes that a value keeps its name on both sides of a function call, but it works the way that many people work.

Visual Perl and Web Services

Visual Perl's code completion is also available for Web services. Once a Web service has been associated with a variable, a list of available methods in the Web service, and their call signatures, will pop up when you type "->".

ActiveState has participated in the development of a scripting-language-agnostic framework for consuming Web services, called the Simple Web Services API. It works with Python and PHP, as well as Perl. Among other things, it allows you to bind to and call methods on a Web service with a minimal amount of code. For Perl, this line suffices to bind a variable to a Web service:

$var = WebService::ServiceProxy->new (wsdl string)

Calling methods off the service is as simple as invoking an object method:

$var->method(args...)

Once a variable has been bound to a Web service, typing the '->' will drop a list of methods the Web service exports, and typing the '(' after the method name will raise a call tip that walks through the arguments.

This is similar to SOAP::Lite, but has the advantage of working in several languages, as well as handling features such as overloaded methods, and supporting method names that contain Unicode characters that can't be used in Perl identifiers.

Conclusion

ActiveState's work with Visual Studio .NET and the .NET Framework furthers our commitment to expanding the use of Perl. Visual Perl expands the language set available to developers using Microsoft's ubiquitous Visual Studio IDE, and PerlNET extends Perl by providing compliancy with the .NET Framework.