#this is a comment print "hello bonnie\n"; print "hello \"anne\"\n"; #escape characters #Perl is case sensitive, try PRINT, it won't work #Literal data = things do not change #Numbric literals (numbers) and string literals #Numbers print 6; #integer print "\n"; #new line print 12.6; #floating point number print "\n"; print 15.; #another floating point number print "\n"; print .732; #yet another floating point number print "\n"; print 1e10; #scientific notation print "\n"; print 6.67E-33; #scientific notation (e or E is acceptable) print "\n"; print 4_294_296;#large number with underscores instead of commas because we cannot put commas into numeric literals print "\n\n"; #Strings, single quotation marks or double quotation marks print "foo!\n"; print "Four thousand years ago\n"; print 'Four thousand years ago\n'; #character in single quote means exactly what it is there, except \' print "\n"; print 'Four thousand years ago, he said "make my day."'; print "\n"; print "Four thousand years ago, he said \"make my day.\""; #\ escape print ""; #Escape characters print "\n"; #newline print "\r"; #carriage return print "\tone\ttwo\tthree\n"; #\t tab print "\uuppercase\n"; #\u change next char to uppercase print "\lLOWERCASE\n"; #\l change next char to lowercase print "\\ \' \""; #literal backslash, literal ', literal " print "\n"; #may skip from here from escape characters print "first"; print "\r"; #carriage return, return to first character of line, weird print "hi"; print "\n"; print "not important"; print "\b"; #backspace print "something was gone due to backspace"; #scalar variables - things that change #variable names are case sensitive (be careful when you type), some are reserved like $_ etc $myvalue = 888; print "\n"; print $myvalue; print "\n$myvalue"; print "\n".$myvalue."\n";; #special variable $_ value is used as "by default", eg. no variable specified or e.g. pattern matching later $_ = "Dark side of the force"; print; #print default value $_ print "\n\n"; #expressions and operators $radius = 50; $area = 3.14159 * ($radius**2); print $area; print "\n"; #more operators - binary $a = 5; $b = 3; print $a+$b."\n"; print $a-$b."\n"; print $a*$b."\n"; print $a/$b."\n"; print $a**$b."\n"; #power print $a%$b."\n"; #modulo (remainder) print "\n"; #unary operators print int(5.62)."\n"; #return integer part print length("nose")."\n"; #return length print lc("DARK SIDE OF THE FORCE")."\n"; #lowercase print uc("dark side of the force")."\n"; #uppercase print rand(5)."\n"; #random number from 0 to less than argument print rand."\n"; #random number from 0 to 1 #angle operator <>, for reading and writing files (later) print "\nwhat size is your shoe? "; $size = ; #need to chomp newline character print "Your shoe size is $size. Thank you!\n"; print "\nwhat size is your shoe? "; $size = ; chomp $size; print "Your shoe size is $size. Thank you!\n";