Perl The Complete Reference 2nd Edition

As the title suggests, this book is a complete reference to the Perl programming language. As such, it includes details of everything you want to know about statements, expressions, functions, and regular expressions within Perl. Some highlights o…

As the title suggests, this book is a complete reference to the Perl programming language. As such, it includes details of everything you want to know about statements, expressions, functions, and regular expressions within Perl. Some highlights of the book include the creation of useful packages and modules, using Perl on the command line and Tk as a cross-platform user interface solution. There are also several chapters dedicated to the design and use of the supported data structures within Perl, and to the processes available for accessing external data structures and databases.Interprocess communication, either between processes on the same machine or between processes on different machines, is also a topic for discussion. The former is handled by a number of tricks and some system-dependent features. For the latter machine communication, you can use network sockets. An alternative solution to the problems of processing between multiple processes is to use threads, which are small, “lightweight” execution sequences that are still owned in their entirety by their parent process, and we also look at how threads can be used to solve these problems.A large portion of the book is given over to the process of getting inside Perl. We examine how Perl works as it parses a Perl script and how that process can be modified with compiler pragmas. Then we move on to the process of extending Perl by writing an interface between Perl and a C function. This allows Perl to use and access an unlimited number of extensions and enhancements to the core Perl language. You can also do the reverse. You can embed the Perl interpreter into a C program, allowing you to use the advanced features of Perl within a C program. You could even build the interpreter into an application to provide a built-in scripting language.A recent development in the Perl interpreter has allowed the creation of a Perl compiler (which is in itself a bit of a misnomer; see Chapter 1 for details). With the compiler you can do many things, including produce some detailed output on the real structure and execution path that your script takes. One of the most significant and useful features, though, is that you can take a Perl script and produce a stand-alone executable program.Perl is also a good cross-platform development tool. See Chapter 1 for a list of some of the platforms that Perl has been ported to. We take a close look at the three main platforms-Unix, Windows, and MacOS-and how they differ, before taking a more generalized view of how to program with Perl in a cross-platform world and ensure the cross-platform compatibility.Finally, the appendixes provide a quick and detailed reference to the Perl functions, error messages, and the standard Perl library that comes with every distribution. Of course, even with the best intentions, it’s possible to have forgotten some element, or not to have gone through a particular element to a deep enough degree, although I hope this won’t be the case for most readers.

Perl: I Didn’t Know You Could Do That

So you’ve downloaded Perl and played with a few of the programs. You might even have been programming with Perl for many years. Either way, you feel you are missing out on some of the cool things that other people are doing with Perl. The solution…

So you’ve downloaded Perl and played with a few of the programs. You might even have been programming with Perl for many years. Either way, you feel you are missing out on some of the cool things that other people are doing with Perl. The solution is Perl: I Didn’t Know You Could Do That. From the mundane processes of web programming, through to creating PostScript and RTF documents, playing music and creating sounds, and even ways to use parts of Perl for something other than they were intended are all contained between the covers of this book.Topics and Examples given in this book:Storing Numbers in Less SpaceCreating Graphs in PerlUsing Minimal/Maximal SearchesParsing an Apache Log FileReading and Writing Audio FilesPlaying Audio CDsHandling PalmOS DatabasesUsing SQL with Text DatabasesTalking HTMLTalking XMLGenerating RTF FilesWriting PostScriptUsing the CGI module to write HTMLBetter Table HandlingSetting up a CookieReading a CookieUsing Sessions to Track a UserCooperating with ApacheUsing Apache AuthenticationFAQ ManagementResolving DNS InformationGetting E-mail from a POP ServerSearching a Search EngineRunning a Socket Based ServerRemote Procedure CallsProfiling Your Perl ScriptsUsing the Compiler for More Than CompilingWriting Perl XtenSionsInstalling Modules from CPANWriting POD DocumentationConverting POD Files on the FlyMonitoring PerformanceMonitoring UptimeCommunicating with SyslogReading and Writing Tar ArchivesUsing Perl to Control Your HomeCommunicating with AppleScriptChecking Windows NT PerformanceTalking to Microsoft WordTalking to Microsoft OutlookWindows NT Service ManagementCreating Stand-Alone Windows Applications

DeBugging Perl

It might surprise you to know that this book is all about debugging Perl scripts and applications. Just like the bug on the front cover, Perl bugs can be annoying and difficult to get rid of and in some cases, just like our little friend, they can…

It might surprise you to know that this book is all about debugging Perl scripts and applications. Just like the bug on the front cover, Perl bugs can be annoying and difficult to get rid of and in some cases, just like our little friend, they can sting you. This book will tell all about how to avoid bugs through better programming, how to trap bugs, and how to debug your program when all the other methods have failed.How much time did you spend debugging your last application? 10% of the total development time? 20%? 40%? It might surprise you to know that the general rule of thumb is that you should spend 80% of your time testing and debugging. The obvious solution is not to introduce bugs in the first place, but there we have a problem.You’re going to see me saying this a lot, but Perl is a very easy and freeform language that just breeds bugs. Perl’s power lies in the way that you can write quite complex applications in only a few lines. Even complex projects like text processing and database management can be handled with relative ease in Perl. However, that power comes at a price. A simple typing error can cause a whole heap of problems in Perl that can be difficult to trace. Turn that into a logic error and you’ve got a bigger problem.Whether they are simple typographical errors, or more significant problems with your code’s logic is largely irrelevant, they’re bugs and they need to be resolved.It’s this debugging process that we cover in this book. In fact, we go a little bit further. I’m a firm believer in good software design, and that means obtaining a better understanding of how the text that you use for a script is translated by the language into a working program. As part of that process, it’s also worth understanding where mistakes can be made during that parsing stage.There are of course problems in your program that can be tracked and caught as part of the program itself ­ for example when you open a file, you should be testing the return value to make sure it was successful. Knowing when and where to use these is a valuable part of the debugging process that can take place during your programs design. You can also use warnings and pragmas to get Perl to do the work for you. If you’ve still got bugs once the program has been completed then you’ll need to know how to use a debugger to find problems.An often forgotten type of bug can be resolved through the use of different optimization techniques. Some things you can spot and resolve manually, but others require the use of special tools to enable the problem functions and program areas to be identified. We can even use the Perl compiler for more than just compiling Perl programs. With a little work and creative thought, we can use the compiler to give us in depth information about a script and provide us with useful starting points for isolating problems.This book covers all of these areas and more, giving you a detailed look at how best to approach the problems of writing less error prone Perl scripts, and at how to resolve and identify bugs after your script has been completed.Who Is the Book For?The book is not targeted at a specific group of Perl users. If you use Perl, then you should be able to use this book. It obviously relies on some knowledge of how to program in Perl, but even beginners can benefit from the tips on better program design and error trapping. In fact, I’d recommend it as a good read for beginners, it should help you to write less bug prone applications!For the more advanced users, or those looking to gain an edge in Perl programming, the sections on optimizing Perl and testing your code are required reading. There’s a lot more to optimization than just reducing the number of times that you call a subroutine, and you’d be amazed at how many external influences can cause problems in your script when you’re not looking.How to Use This BookDebugging Perl is not a reference manual, but a guide on better Perl programming and the tools and features available for debugging Perl. This means that for most Perl programmers, the best approach is to read the first three sections and use the remainder for reference purposes. These will give you a good grounding in how best to write Perl programs with fewer bugs, and how to use the built-in trapping features to isolate possible problems before they become reality.The last two sections should only be used once you are comfortable and familiar with both Perl and the topics introduced earlier in the book. Part 4 in particular is highly focussed on the optimization of scripts and not a high priority for most programmersThe appendix at the back is the main reference section. It contains a list of error messages, with sample code that will raise the error, and solutions to the problem where appropriate. It also provides a cross-reference to other parts of the book where relevant.

ActivePerl Developers Guide

ActivePerl Developer’s Guide has three main focus areas. The first is to help programmers already familiar with Perl under Unix to migrate to the new platform. There are differences between the platforms, both from an architecture and supported fu…

ActivePerl Developer’s Guide has three main focus areas. The first is to help programmers already familiar with Perl under Unix to migrate to the new platform. There are differences between the platforms, both from an architecture and supported function point of view. This book should help you bridge the gap from Perl programming to Windows programming, either by providing a Perl workaround, or by giving you the Windows-specific alternative.The second focus area is on developing applications with the ActivePerl development system. ActivePerl is the version of Perl produced by ActiveState which is already compiled and optimized for the Windows platform. ActivePerl is supplied as an installable application, thereby overcoming the biggest hurdle, that of compiling Perl on the Windows platform. ActivePerl also provides us with some features not offered in the standard Perl, including an extensive Windows specific library, a Perl Package Manager (similar to the CPAN module) and some neat abilities that help you develop Perl based web sites on Windows servers.The last focus area concentrates on helping people already familiar with programming Windows using Visual Basic and provides a guide for migrating their programming skills from VB to Perl.What this book is not is a tutorial guide to programming with Perl under Windows, or a complete reference to Perl for Windows programmers ­ many of the Perl functions and library are ignored if there are no differences between Unix and Windows implementations. Furthermore, it’s not a complete guide to applications development ­ we won’t be covering algorithms, or providing solutions to your development problems.We will, on the other hand, provide you with all the information you should ever need to enable you to develop applications using ActivePerl and the Win32 specific Perl libraries. Armed with that information, and providing you have an existing understanding about how to program with Perl, then you should be able to produce any application you like using this book and ActivePerl.Who Is the Book For?The target audience is directly split into two groups ­ existing Unix Perl programmers who need to develop a Windows specific or compatible application, and Visual Basic programmers who want to learn how to program in Perl.If you are in the former category, you’ll need to know Perl to a reasonable level already. The book is not a tutorial guide (although the last section may help). We’ve made the assumption that you already know how to program in Perl and know the basic operations and development processes behind writing a Perl script.For Visual Basic programmers, you’ll need to be well versed in VB, but not necessarily an expert. The last section gives a quick introduction to the Perl language, so providing you know how to program you should be able to pick up the Perl language quite quickly.How to Use This BookIf you are a Unix programmer, I suggest you use it as a reference in combination with another guide, such as Perl: The Complete Reference, to enable you to program in Perl under Windows. You should be able to find everything you need for successfully migrating your Unix Perl applications to Windows. If there’s something missing, let me know, and I’ll see what I can do.For Visual Basic programmers, skip to the last section, which gives an outline and overview of the differences, and then follows with a number of different aspects that are different between the two languages. Armed with this information, and the function migration guide in Appendix C, you should be up and running as a Perl programmer in no time at all.

iMac FYI

The iMac is the biggest selling computer of all time, and it’s not really hard to see why. Aside from being an excellent little computer, it’s also beomce a fashion statement with designers, stylists, and joe public all clamouring for a piece of a…

The iMac is the biggest selling computer of all time, and it’s not really hard to see why. Aside from being an excellent little computer, it’s also beomce a fashion statement with designers, stylists, and joe public all clamouring for a piece of a modern classic in their home.The iMac broke the mould in computing – something that not only worked nicely, but also looked nice. The only problem is, not everybody is as clued up as they would like on how to make the best of their new machine. Simple questions like ‘How do I change my desktop’ and ‘How can I play a game against my mate’ are regular topics on forums, newsgroups, and user group meetings worldwide.The iMac FYI book aims to answer those, and many more questions regarding your iMac. How to network machines together, make the best of the Internet, backup your data, fix your machine when it breaks. We even provide details of how best to configure your machine when you first get it out of the box.

Python Annotated Archives

This book is intended to be a guide to scripting with the Python language. It is not, however, a complete guide to the Python language, nor is it an attempt to demonstrate the only way to achieve a particular result in Python. Instead, this book a…

This book is intended to be a guide to scripting with the Python language. It is not, however, a complete guide to the Python language, nor is it an attempt to demonstrate the only way to achieve a particular result in Python. Instead, this book aims to demonstrate ways of using Python in real world situations. I show you real world scripts and annotate them to describe both the logic being used and the Python-specific features being employed to achieve a goal.About PythonPython is an interpreted language that employs an object-oriented approach. It’s a high-level programming language, which means that it separates the user from the underlying operating system as much as possible. However, unlike other languages, Python provides you with the ability to access the OS at a lower level if you desire. Because of this ability, Python is often pitched somewhere between such languages as Visual Basic and Perl and the system language of C.Although it is classed as an interpreted language, like Perl it employs a compilation stage that translates the raw Python script into a series of byte codes, which are then executed. These byte codes can be saved into a new file to enable faster execution of Python problems. The use of the compilation and byte code stages helps to improve performance and makes Python much faster than pure interpreters.Python also has the added benefit of providing rapid application development on the MacOS, Windows (95/98/NT), and Unix platforms. Python is supplied with a module to the Tk interface builder, and it’s possible to write an application on one platform and use it on all three platforms without making any modifications. In addition to the core platforms, Python also runs on MS-DOS, Amiga, BeOS, OS/2, VMS, QNX, and many more operating systems.Python has been around for many years now and has a strong following from a number of well-known companies for many different purposes. These companies include NASA, which uses it for their Integrated Planning System; Infoseek, which sells a Python-based search engine product called Ultraseek Server; and Red Hat, which uses it in their Linux product for configuration and administration tasks.One final note for those wondering what “Python” stands for: basically it doesn’t. Guido van Rossum selected the word because he is a big fan of Monty Python, a popular comedy group consisting of the talents of John Cleese, Eric Idle, Michael Palin, Terry Jones, Terry Gilliam, and Graham Chapman. Although I will admit to also being a huge fan of Monty Python, this connection has in no way influenced my love of Python. Well, not much…Who This Book Is ForUnlike many other programming books, this title is not designed to be a reference or language guide, nor is it targeted at a particular set of users. If you program in Python, or think you might like to program in Python, you should find this book useful.If you’re evaluating or just starting to learn Python, this book provides you with some examples and guidance on how to make the best use of Python and what it can be used for. All of the scripts in the book work straight off of the page (or the supplied CD-ROM) and demonstrate the range of features and abilities of the Python language.If you’re an intermediate programmer, this book helps to serve as a guide for improving your programming skills. It also provides a wider view of the available modules and extensions for the Python language and how they can be employed in your current development projects.If you’re a more advanced programmer, the scripts contained in the book can help augment or form the core of Python development efforts. They might even provide you with examples and ideas for using Python that you hadn’t before considered.In all cases, and for all programmers, the scripts provided here are intended to demonstrate the different features of the Python language and the ways in which you can use different methods to achieve the same or a similar result. All of the scripts can be taken from the supplied CD-ROM and used on your machine. You may have to account for minor differences, such as filenames and locations, but otherwise the scripts should work unmodified. If not, please let me know.

Perl Programmers Reference

Perl Programmers is the quick desktop tool for checking up on different Perl features. Split into 6 sections it includes the basics (syntax, variables, functions, references, regular expressions, formats and POD document formats), a complete funct…

Perl Programmers is the quick desktop tool for checking up on different Perl features. Split into 6 sections it includes the basics (syntax, variables, functions, references, regular expressions, formats and POD document formats), a complete functional reference, comprehensive guide to the Perl standard library, a suite of example scripts, information on using Perl on the command line, threads, the Perl Compiler and the Perl debugger.