Script
1 #!/usr/bin/perl -w
2
3 use strict;
4
16 while (my $input = <DATA>){
17 chomp($input);
18 my ($name,$num,$addr,$date,$n) = split(":", $input);
19 my ($fname,$lname) = split(" ",$name);
20 print "$lname\n" if $lname =~ /^ker/;
21 }
22 print "\n";
23
24
25 __DATA__
26 Tommy Savage: 408–72 4–0140: 12 2 2 Oxbow Court, Sunnyvale, CA 940
+87: 5/19/66: 34200
27 Lesle Kerstin: 408–456–1234: 4 Harvard Square, Boston, MA 02133: 4
+/22/62: 52600
28 JonDeLoach: 408–253–3 122: 12 3 Park St. , San Jose, CA 94086: 7/2
+5/53: 85100
29 Ephram Hardy: 293–259–5395: 2 3 5 Carlton Lane, Joliet, IL 73858:
+8/12/20: 56700
30 Betty Boop: 245–836–83 57: 63 5 Cutesy Lane, Hollywood, CA 91464:
+6/23/23: 14500
31 William Kopf: 846–83 6–2837: 693 7 Ware Road, Milton, PA 93756: 9/
+21/46: 43500
32 Norma Corder: 397–857–2735: 74 Pine Street, Dearborn, MI 23874: 3/
+28/45: 245700
33 James Ikeda: 834–938–8376: 2 3 445 Aster Ave. , Allentown, NJ 8374
+5: 12/1/38: 45000
34 Lori Gortz: 327–832–5728: 3465 Mirlo Street, Peabody, MA 34756: 10
+/2/65: 35200
35 Barbara Kerz: 385–57 3 –8326: 83 2 Ponce Drive, Gary, IN 83756: 12
+/15/46: 268500
Result
:~/pbe/chap8$ ./exer1.pl
Use of uninitialized value $lname in pattern match (m//) at ./exer1.pl
+ line 20, <DATA> line 3.
Use of uninitialized value $name in split at ./exer1.pl line 19, <DATA
+> line 11.
Use of uninitialized value $lname in pattern match (m//) at ./exer1.pl
+ line 20, <DATA> line 11.
Use of uninitialized value $name in split at ./exer1.pl line 19, <DATA
+> line 12.
Use of uninitialized value $lname in pattern match (m//) at ./exer1.pl
+ line 20, <DATA> line 12.
Use of uninitialized value $name in split at ./exer1.pl line 19, <DATA
+> line 13.
Use of uninitialized value $lname in pattern match (m//) at ./exer1.pl
+ line 20, <DATA> line 13.
Use of uninitialized value $name in split at ./exer1.pl line 19, <DATA
+> line 14.
Use of uninitialized value $lname in pattern match (m//) at ./exer1.pl
+ line 20, <DATA> line 14.
Use of uninitialized value $name in split at ./exer1.pl line 19, <DATA
+> line 15.
Use of uninitialized value $lname in pattern match (m//) at ./exer1.pl
+ line 20, <DATA> line 15.
Question
I am very confused with uninitialized errors, can anyone explain how to fix it. thanks!!