Hey all. I got stuck on a quetion in "Intermediate Perl" by Randal L. Schwartz, brian d, foy & Tom Phoenix. So I went over the answer in the back.
I am pretty sure I understand how the problem is supposed to work but I don't quit understand why the code won't run on my machine. Can anyone enlighten me?
Code:
#!/usr/bin/perl -w
#distlog.pl
use strict;
use IO::File;
my %output_handles;
while (<>) {
unless (/^(\S+):/) {
warn "ignoring the line with missing name: $_";
next;
}
my $name = lc $1;
my $handle = $output_handles{$name} ||=
IO::File->open(">$name.info") || die "Cannot create $name.info: $!";
print $handle $_;
}
Error:
Can't use string ("IO::File") as a symbol ref while "strict refs" in u
+se at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/IO/File.pm lin
+e 188, <> line 1.
Thanks,
-Actualize