Introduction to Perl - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Introduction to Perl

Description:

Programming languages are just like speaking languages, they all need to show ... n n is used as a carriage return. Ex. print 'I am a Winner! n'; More With Print ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 8
Provided by: test243
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Perl


1
Introduction to Perl
  • Unit 2 Print More

2
The Print Function
  • The print function is the easiest way to display
    your text to the screen.
  • The Syntax for the print function is displayed as
    such
  • print Your text here
  • Programming languages are just like speaking
    languages, they all need to show when they are
    done. Periods are used for verbal languages and
    semicolons () are used in perl.
  • To move text to the next line for the next print
    statement, finish the line with \n for next
    line. Also if you hit return before closing your
    quotes, you will have those returns in your
    output.

3
Same Thing Again Does it make any more sense
now?
  • Print is a command ? you need to tell it what you
    want to print
  • Ex. print I am a Winner! \n
  • Your print statement ? quotes define what the
    print statement is going to say. Without them
    Perl does not know what you want to print
  • Ex. print I am a Winner! \n
  • ? must be at the end of (almost) every line
  • Ex. print I am a Winner! \n
  • \n ?\n is used as a carriage return
  • Ex. print I am a Winner! \n

4
More With Print
  • You can print variables using commas.name
    Tonyprint A name might be , name, \n
  • You can print variables inside of quotes.name2
    Markprint Another popular name is name2
    \n

5
Pre-Programming Steps
  • Before programming in any language, it is
    important to take note of a couple things. (Sorta
    like packing before going on vacation).
  • What Variable Types/ of Variables Needed
  • Can you program this in your head?
  • Do you know all the functions you will need?
  • Formulas
  • Anything Else

6
Debugging
  • Errors can be run time or compile time.
  • Compile time errors give you a hint.
  • The program wont run and the error is referenced
    by line number.
  • For run time errors, print is your friend.
  • Large numbers of print statements can clue you in
    on what your program is doing.

7
Commenting Reminder
  • Commenting is done in Perl to make your code
    more understandable to other coders as well as to
    help you pick up where you left off.
  • Comments in Perl are marked with the hash sign
    () which works like to the double slashes ( // )
    in C or Java.
  • e.g. Insert Comments Here
  • Be sure to use comments where appropriate

Print Exercises
Write a Comment
User Comments (0)
About PowerShow.com