Download presentation
Presentation is loading. Please wait.
Published byEunice Bradford Modified over 9 years ago
1
Perl Lab #11 Intro to Perl Debbie Bartlett
2
Perl Lab #1 2 Perl Practical Extraction and Report Language –or- Pathologically Eclectic Rubbish Lister Created by Larry Wall in 1987 Originally developed when he found limitations in the tools he was using for report generation Borrowed features from other languages such as C, shell scripting, AWK, sed, and Lisp Interpreted language Why use Perl? Extract information from a text file and print out a report Convert a text file into another form Lots of other tasks!
3
Perl Lab #1 3 Perl Scripts Creating a Perl Script Use a text editor such as gedit or emacs Type in your program Name the file filename.pl Set execution permission bit, i.e. chmod 755 filename.pl Type the command name, filename.pl, at your terminal window shell prompt
4
Perl Lab #1 4 Sample Perl Script #! /usr/bin/perl print “What is your name?”; $name = ; chomp ($name); if ($name eq “Debbie”) { print (“Hello, Debbie! I am glad that you are in CS192 today!\n”); } else { print (“Hello, $name!\n”); # ordinary greeting }
5
Perl Lab #1 5 Perl1 Lab Assignment Type in your version of the Perl script (slide #4) Ask a second question in your Perl script What happens if you leave out the chomp statement? Take it out, try it, and then put it back What happens if you leave off the “;” after “What is your name? “ Take if off, try it, and then put it back What happens if you leave off the quote after “What is your name? – Take if off, try it, and then put it back Look in Google for “while” loop. Add a while loop to your Perl script? Show your script to a lab instructor or helper
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.