A Testbed for PerlNET

If you're like most programmers, you don't want to start a programming book with a lot of theory, but would like to get your feet wet with a little programming right away. This section is intended to get you up and running using the .NET Framework SDK and PerlNET. If you want to continue in hands-on mode, you can then proceed directly to Chapter 2. If you would like to get some .NET theory under your belt, you could read the rest of this chapter.

Installing the .NET SDK

The first tool you need to compile and run the programs in this book is the .NET Framework SDK. This SDK is available on CD or can be downloaded for free from the Microsoft .NET Web site, http://msdn.microsoft.com/net/. Follow the installation directions for the SDK, and make sure that your computer meets the hardware requirements. (A rule of thumb for the SDK is that you need a fast Pentium processor and at least 128M of RAM.) The recommended software requirements include Windows 2000 or Windows XP. Part of the installation is a Windows Component Update, which updates your system, if necessary, to recent versions of programs such as Internet Explorer. The SDK installs tools such as compilers, documentation, sample programs, and the CLR.

The starting place for the SDK documentation is the .NET Framework SDK Overview (see Figure 1-1).

Figure 1-1. Homepage of .NET Framework SDK.


Installing the Perl Dev Kit (PDK)

The second tool you need is the Perl Dev Kit, or PDK, from ActiveState. The PDK can be downloaded from the ActiveState Web site, www.ActiveState.com. Follow the installation directions for the PDK. If your system meets the hardware and software requirements for the .NET Framework SDK, you will automatically meet the requirements of the PDK, which are less stringent. The PDK installs tools such as PerlApp, PerlCOM, PerlNET, and HTML documentation. Figure 1-2 illustrates the home page of the PDK documentation.

Figure 1-2. Homepage of the PDK documentation.


Installing the Book Software

The example programs found in this book are available on the Web site http://www.objectinnovations.com/dotnet/. Download the file Install_NetPerl.exe. Then, run this self-extracting file. If you accept the suggested installation directory, the software will be installed in the directory OINetPerl on your C: drive. There are subdirectories for each chapter of the book. The directory for Chapter 1 is Chap01. Sample programs are in named subdirectories of the chapter directory, and we refer to these sample programs simply by name, such as Hello.

Your First PerlNET Program

Although we won't actually start to examine the structure of PerlNET programs until Chapter 9, you don't have to wait to compile and run your first PerlNET program. Start the command prompt and navigate to the HelloPerlNETdirectory for this chapter (if you accepted the default installation, the directory is c:OIPerlNetChap01HelloPerlNET). The source file is Hello.pl. To compile this program, enter the following command:


>plc hello.pl

The file Hello.exe will be created, which you can now run.

>hello
Hello World!

Perl and PerlNET

If you have previously worked with Perl, you may be a bit confused by the concept of “compiling” a Perl source file into an “executable” file such as Hello.exe. After all, Perl is an interpreted language. The normal way you program with Perl is to run the Perl interpreter against a Perl script file. As an illustration, go to the folder Chap01HelloPerl. You can then run the Perl script HelloPerl.pl by the command perl helloperl.pl, which invokes the Perl interpreter.

What is happening when you use the PerlNET compiler to create an executable? Ordinary, IL code is generated. The IL code calls the Perl interpreter to execute Perl statements.

Also, if you compare the files in HelloPerlNET and HelloPerl, you will see that the first file uses the .NET class Console to perform output, while the second file uses the Perl print statement. These concepts are described in more detail in Part 2 of this book.


Visual Studio .NET and Visual Perl

Although the PDK and .NET Framework SDK are all you need to compile and run PerlNET programs, the process is much easier and more pleasant if you use the Visual Studio .NET integrated development environment (IDE). The IDE provides an easy-to-use editor, access to the compiler and debugger, and access to online help. Visual Perl is an add-on, which allows you to work with Perl projects quite seamlessly with the Visual Studio environment. We discuss Visual Studio .NET and Visual Perl in Appendix A.

Understanding .NET

If you are eager to start learning about PerlNET programming right away, and you already know Perl, by all means proceed directly to Chapter 9. The nice thing about a high-level programming language is that, for the most part, you do not need to be concerned with the platform on which the program executes (unless you are making use of services provided by the platform). You can work with the abstractions provided by the language and with functions provided by libraries.

However, you will appreciate PerlNET and its potential for creating sophisticated applications better if you have a general understanding of .NET. The rest of this chapter is concerned with helping you to achieve such an understanding. We address three broad topics:

  • What Is Microsoft .NET?

  • .NET Framework

  • Common Language Runtime

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.132.214