On Fri, Jul 2, 2010 at 07:59, perl_haxor 123 <[email protected]> wrote:
> Hi All,
>
> I have been asked to parse the log file (find the attached file)
> which logs every keystroke, if you look at the log file you will see lot of
> characters like RETURN, BACKSCAPE etc etc........Is there a way by which i
> can make sense of this log file, so that i can write a script to parse
> it.....It would be great if someone can help me solve this problem.
snip
I would say you can get 80% of the way there by
* treating each line as if it where a separate command
* treating the backspace (^H) and delete (^?) characters as backspaces
* ignoring (ESC)
but there will certainly be problems with this solution.
#!/usr/bin/perl
use strict;
use warnings;
while (<>) {
s/\(ESC\)//g; #remove escapes
my @visible;
for my $char (split //) {
if (ord $char == 8 or ord $char == 127) {
pop @visible;
next;
}
push @visible, $char;
}
print @visible;
}
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/