1 / 7

Running a Perl Program

Running a Perl Program. #!/usr/bin/perl5.00404 print(“Howdy, world!<br>”); # comment Make sure the file is executable: chmod +x howdy.pl ./howdy.pl. Online help. perldoc perl (overview) perldoc perlfaq (freq. asked questions) perldoc perldata (data structures)

dea
Download Presentation

Running a Perl Program

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Running a Perl Program #!/usr/bin/perl5.00404 print(“Howdy, world!\n”); # comment Make sure the file is executable: chmod +x howdy.pl ./howdy.pl CSE 341 - S. Tanimoto Perl -

  2. Online help perldoc perl (overview) perldoc perlfaq (freq. asked questions) perldoc perldata (data structures) perldoc perlsyn (syntax) perldoc perlop (operators and precedence) perldoc perlre (regular expressions) perldoc perlrun (execution and options) etc. (see Schilli, p.3) CSE 341 - S. Tanimoto Perl -

  3. Data Types $n = 25; # a numeric scalar $str = “Here is a string”; print(‘The value of $n is ‘ . $n); # Note strings with ‘ ‘ do not have # variable “interpolation performed” # But strings with “ “ DO have it. print(“The value is $n.”); CSE 341 - S. Tanimoto Perl -

  4. String Operations “string1” . “string2” # concatenation Can also be done using interpolation: $str1 = “abc”; $str2 = “def”; $newstr = “$str1$str2”; CSE 341 - S. Tanimoto Perl -

  5. Immediate (“Here”) Documents print <<“END-OF-PRINT”; Hello there. This is a two-line immediate text doc. END-OF-PRINT $mytext = <<TextEnd This is some text that ends on a blank line TextEnd CSE 341 - S. Tanimoto Perl -

  6. Arrays @trees = (“Oak”, “Maple”, “Madrona”); @moretrees = qw(pine alter hemlock); @ages = (75, 50.5, “twenty); $mytree = $trees[1]; # “Maple” CSE 341 - S. Tanimoto Perl -

  7. Hashes (Associative Arrays) $foodtype{‘Spaghetti’} = ‘Italian’; $thetype = $foodtype{‘Spaghetti’}; foreach $food (keys %foodtype) { $thetype = $foodtype{$food}; print “Food $food is $thetype\n”; } CSE 341 - S. Tanimoto Perl -

More Related