These are the code samples that we built in class.
#!/usr/bin/perl use strict; use warnings; sub say_hello { my $name = shift; $name .= "!"; print "Hello, $name\n"; } say_hello("world"); my $name = <STDIN>; chomp($name); say_hello($name); print "original name: '$name'\n";
#!/usr/bin/perl use strict; use warnings; sub slurp { my $filename = shift; open(INPUT, $filename) or die "help!: $!\n"; my @contents = <INPUT>; close(INPUT); return @contents; } my @file_contents = slurp('day5b.pl'); print "number of lines: " . scalar(@file_contents) . "\n";