[localhost:~/Perl] lynda% more hello.pl #!/usr/bin/perl -w # my first perl hello program # starting Perl (#!, -w), Perl statements, comments (#), # print, scalar text strings, double quoted strings, # ending Perl (exit) print "Hello world!"; exit; [localhost:~/Perl] lynda% perl hello.pl Hello world![localhost:~/Perl] lynda% ====================================== [localhost:~/Perl] lynda% more hello2.pl #!/usr/bin/perl -w # hello2.pl, using \n print "Hello world!\n"; exit; [localhost:~/Perl] lynda% perl hello2.pl Hello world! [localhost:~/Perl] lynda% ===================================== [localhost:~/Perl] lynda% more hello3.pl #!/usr/bin/perl -w # hello3.pl, single quoted strings (' instead of ") print 'Hello world!\n'; exit; [localhost:~/Perl] lynda% perl hello3.pl Hello world!\n[localhost:~/Perl] lynda% ====================================== [localhost:~/Perl] lynda% more hello4.pl #!/usr/bin/perl -w # hello4.pl, receiving input from the keyboard (), # scalar variable, assignment statement, # printing a scalar variable # scalar variable name: "$" followed by a letter or # underscore, and one or more alphanumeric characters # or underscores. print "What is your name?\n"; $name = ; print "Hello, $name!\n"; exit [localhost:~/Perl] lynda% perl hello4.pl What is your name? Lynda Hello, Lynda ! [localhost:~/Perl] lynda% ====================================== [localhost:~/Perl] lynda% more hello5.pl #!/usr/bin/perl -w # hello5.pl, receiving input from the keyboard (), # scalar variable, assignment statement, # removed \n from question; removed \n from response (chomp) # printing a scalar variable print "What is your name? "; $name = ; chomp ($name); print "Hello, $name!\n"; exit; [localhost:~/Perl] lynda% perl hello5.pl What is your name? Lynda Hello, Lynda! [localhost:~/Perl] lynda% perl hello5.pl What is your name? Lynda Ellis Hello, Lynda Ellis! [localhost:~/Perl] lynda% ====================================== [localhost:~/Perl] lynda% more hello6.pl #!/usr/bin/perl -w # hello6.pl, receiving input from the user # chomp and assignment on same line print "What is your name? "; chomp ($name = ); print "Hello, $name!\n"; exit; [localhost:~/Perl] lynda% perl hello6.pl What is your name? Lynda Hello, Lynda! [localhost:~/Perl] lynda% ==========================================