ACM Reections Projections Perl Tutorial


ACM Reections Projections Perl Tutorial cover page
ACM Reections Projections Perl Tutorial Stephen Saville 14 Oct2001 1 A Brief Introduction to Perl Now, everybody’s solution to a system administration problem is not to write a new … … language, but that’sexactlywhat Larry Wall did back in 1987 when he found the newsreader rn (which he also wrote) to beinsucient for the task. In the years since then, Perl, the”Practical Extraction and Report Language,”or” Pathologically Eclectic Rubbish Lister,”depending on who you talk to, has grown from a one-person hack to a community …

With its powerful and well-developed module system, including tie-ins to many useful C libraries, the possibilities with perl and endless. Nevertheless, most of these uses are beyond the scope of this tutorial. The focus of this tutorial is rather on the Perllanguage itself, and a few of its main strengths. After working through this tutorial or attending the Reections Projections workshop, you should have a basic grasp of the fundamental aspects of the Perl language, and enough knowledge to get something out of the references listed at the end of this tutorial. 1.1 Starting Perl The simplest way to start Perl is just by running the Perl program with no arguments. In this tutorial, every line that begins witha’%’should be interpreted asashellcommmand. So type’perl’on the command line and press enter: %perl… 1 A BRIEF INTRODUCTION TOPERL 2 You have now invoked the Perlinterpreter! Patienlythe interpreter sits there, waiting for you to type in some Perlcodeforitto compile. Let’sgive it some Perltoplay with: %perl print”Ilike Perl\n”; When you’redone, just type Ctrl-Dtotell Perlyouhave nishedwriting the program. Now, the interpreter can go to work executing your Perlcode: %perl print”Ilike Perl\n”; Ilike Perl As you can see, once Perl nishesexecuting your code, it returns you back to the command prompt so you can do whatever other work you might want to accomplish. However, this is not the only way touse Perl, forby thePerlmotto: “There’smorethanoneway to doit” (often abbreviated TMTOWTDI). You could also have createda lecalled, say\ script.pl”, with some Perlcode in it and then run it through the Per linterpreter with the command: %perlscript.pl Alternatively, you could use thee switch to have Perl run a small bit of code. This method is calleda Perl one liner. %perl-e’print(”Ilike Perl”);’ Finally (for our purposes), you could make the a le containing Perl code (ascript) executable by either setting its viewer to be the Perl programin Windows or putting the following text on the rstlineofascript leinUnix: #!/usr/bin/perl-w Under Unix, you would also have to make the program executable before you could run it by setting the execute lepermission with: %chmoda+xscript.pl Then, theperlprogram could be run with the command: %./script.pl

Download ACM Reections Projections Perl Tutorial.Pdf

Leave a Reply