Perl Chapter 1

828 views
757 views

Published on

Intoduction to Perl (under Windows XP)

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
828
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Perl Chapter 1

  1. 1. P age |1 PERL –Chap 1Getting Started: 1. Perl – Practical Extraction and Report Language 2. Main site for learning Perl: http://www.perl.org 3. For Windows (x86 system), version installed : ActivePerl5.12.13 site: www.activestate.com/activeperl 4. Install Perl – default location will be C:Perl 5. Perl – interpreter based 6. Mainly used for text-based work. 7. Caution!! – source code must be provided to user; Perl can’t create opaque binaries (binary files) and so no privacy of source code. 8. More info on Perl, problems – google it!My First Program in Perl 1. Create a folder : C:perlscripts 2. In Notepad, type the following: #!/usr/bin/perl print "Hello World.n"; print "Here I come";Save this file as hello.pl in the folder perlscriptsNote: Filename extension is .plRun the program from DOS prompt and immediately the output is displayed like this:C:perlscripts>hello.plHello WorldHere I comeC:perlscripts>Caution: Some books may suggest that the filename extension of .pl is not required. But if filenameextension is given, the perl interpreter is used by default. If you don’t give the filename extension of .pl,then to run the same program, you will have to give the command as follows:C:perlscripts>perl helloThis will run the program as well.In general, it’s a good idea to give your Perl programs the extension of .plProf. Mukesh N Tekwani mukeshtekwani@hotmail.com
  2. 2. P age |2Comments in Perl programs:All comments begin with the # character. Comments can appear at the end of a Perl statement, like this:print "Hello World.n"; #this is a greetingThere are no block comments in PerlAnalysis of the first program:The very first line is #!/usr/bin/perlOn Unix systems, if the first two characters on the first line of a text file are #!, what follows is the anme ofthe program that actually executes the rest of the file; in this case the file that is used is perl stored in binfolder.On Windows-based system, this first line can also be written as #! perlThis gives the information that it’s a perl program. But this line is optional under Windows, if you have donethe default installation. The installation also sets the Path under Windows OS, so Windows knows where tofind the interpreter perl.exe.How does my program run under Perl?When you run your program, Perl’s internal compiler first runs through the entire source code, andconverts it into an internal bytecode.After that, Perl’s bytecode engine takes over and actually runs the bytecode. If there’s a syntax error on aline, say line 10, you’ll get that error message.Prof. Mukesh N Tekwani mukeshtekwani@hotmail.com

×