Permalink
Browse files

2012-4-24 from zhao-laptop

  • Loading branch information...
1 parent 0a2ed64 commit 4fa3eeaeaed65ef1e20ba8fe2245f6f6fd89959c @zhaowe committed Apr 24, 2012
Showing with 20 additions and 0 deletions.
  1. +10 −0 ex6-1.pl
  2. +10 −0 ex6-2.pl
View
@@ -0,0 +1,10 @@
+#! /usr/bin/env perl
+
+# This program will ask the user for a given name
+# and report the corresponding family name.
+
+use warnings;
+
+%family_name=(fred=>'flintstone',barney=>'rubble',wilma=>'flintstone');
+chomp($given_name=<STDIN>);
+print "$family_name{$given_name}\n";
View
@@ -0,0 +1,10 @@
+#! /usr/bin/env perl
+
+# This program reads a series of words until end-of-input, then prints
+# a summary of how many times each word was seen.
+
+use warnings;
+
+while($_=<STDIN>){ chomp; $summary{$_}+=1; }
+
+while(( $key,$value)=each %summary){ print "$key: $value\n"}

0 comments on commit 4fa3eea

Please sign in to comment.