#!/usr/bin/perl -w use strict; my $wtmp_fmt = 'x44 A32 x264 l x40'; open(WTMP, './wtmp') || die "Unable to open wtmp file: $!\n"; my $rec; my $rec_size = length pack ($wtmp_fmt, ()); my $reccount = 0; while (read(WTMP, $rec, $rec_size)) { $reccount++; print length $rec, ' - '; if (length $rec < $rec_size) { print "\n"; last; } my @data = unpack($wtmp_fmt, $rec); my $name = $data[0] || ''; my $logtime = localtime($data[1]) || ''; print "$name\tat $logtime\n"; } close WTMP; print "$reccount records read\n";