:::::::::::::: example03.txt :::::::::::::: :::::::::::::: example1 :::::::::::::: print "Hello", "world", "\n"; print "Hello world\n"; :::::::::::::: :::::::::::::: example2 :::::::::::::: # This is a Perl script. print Hello, world, "\n"; :::::::::::::: example3 :::::::::::::: # This is a Perl script. print STDOUT Hello, world, "\n"; :::::::::::::: example4 :::::::::::::: #! /usr/bin/perl # Program to illustrate printing literals print "The price is $100.\n"; print "The price is \$100.\n"; print "The price is \$",100, ".\n"; print "The binary number is converted to: ",0b10001,".\n"; print "The octal number is converted to: ",0777,".\n"; print "The hexadecimal number is converted to: ",0xAbcF,".\n"; print "The unformatted number is ", 14.56, ".\n"; :::::::::::::: example5 :::::::::::::: #! /usr/bin/perl print "***\tIn double quotes\t***\n"; # backslash interpretation print '%%%\t\tIn single quotes\t\t%%%\n'; # All characters are # printed as literals print "\n" :::::::::::::: example6 :::::::::::::: #! /usr/bin/perl print "\a\t\tThe \Unumber\E \LIS\E ",0777,".\n"; :::::::::::::: example7 :::::::::::::: #! /usr/bin/perl # Program name: literals.perl # written to test special literals print "We are on line number ", __LINE__, ".\n"; print "The name of this file is ",__FILE__,".\n"; __END__ And this stuff is just a bunch of chitter-chatter that is to be ignored by Perl. The __END__ literal is like ctrl-d or \004. :::::::::::::: example8 :::::::::::::: #! /usr/bin/perl # Program name: literals.perl2 # written to test special literal __DATA__ print ; __DATA__ This line will be printed. And so will this one. :::::::::::::: example9 :::::::::::::: #! /bin/sh perl -w warnme example10 :::::::::::::: #! /usr/bin/perl # Program name: warnme2 use warnings; print STDOUT Ellie, what\'s up?; :::::::::::::: example11 :::::::::::::: #! /usr/bin/perl # Program: stricts.test # Script to demonstrate the strict pragma use strict "subs"; $name = Ellie; #Unquoted word Ellie print "Hi $name.\n"; :::::::::::::: example12 :::::::::::::: #! /usr/bin/perl printf("The name is %s and the number is %d\n", "John", 50); :::::::::::::: example13 :::::::::::::: #! /usr/bin/perl printf "Hello to you and yours %s!\n","Sam McGoo!"; printf("%-15s%-20s\n", "Jack", "Sprat"); printf "The number in decimal is %d\n", 45; printf "The formatted number is |%10d|\n", 100; printf "The number printed with leading zeros is |%010d|\n", 5; printf "Left-justified the number is |%-10d|\n", 100; printf "The number in octal is %o\n",15; printf "The number in hexadecimal is %x\n", 15; printf "The formatted floating point number is |%8.2f|\n", 14.3456; printf "The floating point number is |%8f|\n", 15; printf "The character is %c\n", 65; :::::::::::::: example14 :::::::::::::: #! /usr/bin/perl $string = sprintf("The name is: %10s\nThe number is: %8.2f\n", "Ellie", 33); print "$string"; :::::::::::::: example15 :::::::::::::: # This is a Perl script. $price=1000; # A variable is assigned a value. print <