#!/usr/bin/perl # script to demonstrate various features in class #################### # Printing scalars # #################### print 3 + "2"; # prints 5, followed by prompt on same line #print 3 + "2\n"; # prints 5, followed by prompt on same line # \n is pruned off end when using string as a number #print 3 + "2","\n"; # prints 5 followed by prompt on next line #################### # Escape sequences # #################### #print "Tabs are represented by the \t sequence of chars.\n"; #doesnt print \t # Fix #print "Tabs are represented by the \\t sequence of chars.\n"; #doesnt print \t # print "She said "I prefer pi"\n"; # Error # Fix # print "She said \"I prefer pi\"\n"; # Error #################### # Scalar variables # #################### $fred = 2; $joe = "I have ".$fred." dogs."; #print $joe; #print "\n"; #print "I have ".$fred." dogs.\n"; # OR #print "I have $fred dogs.\n"; # shorthand for $joe = $joe." and no cats"; #$joe .= " and no cats."; #print $joe; #print "\n"; #################### # Logical ops # #################### # non-zero is true! if ( 30 != (25 + 5)){ print "TRUE\n"; }else { print "FALSE\n"; } # print "Boolean tests:\n"; # print "kirby" lt "nacho"; # print "\n"; # print "Kirby" lt "nacho"; # print "\n";