That's because you can't copy and paste the entire thing as a .pl file and expect Perl to understand. Here's what you need to have as the contents of the .pl file:
#!/bin/perl
@type = (
"Empty", "Run Lvl", "Boot", "New Time", "Old Time", "Init" +,
"Login", "Normal", "Term", "Account"
);
$recs = "";
while (<>) {
$r ecs .= $_;
}
foreach ( split( /(.{384})/s, $recs ) ) {
next if length($_) == 0 +;
my ( $type, $pid, $line, $inittab, $user, $host, $t1, $t2, $t3, $t
+4, $t5 ) =
$_ =~ /(.{4})(.{4})(.{32})(.{4})(.{32})(.{256})(.{4})(.{4})(.{4}
+)(.
+{4})(.{4})/s;
if ( defined $line && $line =~ /\w/ ) {
$line =~ s/\
x00+//g;
$host =~ s/\x00+//g;
$user =~ s/\x00+//g;
printf(
"%s %-8s %-12s
+%10s %-45s \n",
scalar( gmtime( unpack( "I4", $t3 ) ) ),
$type[
unpack( "
I4", $type )
],
$user,
$line,
$host
);
}
}
printf "\n"
The next step after saving your .pl file is to make it executable using the chmod command. A chmod u+x,g+x,o+x wtmp.pl will do it. Then you can run the script like so:
./wtmp.pl
The above assumes that wtmp.pl is in your current directory.