use strict; use warnings; use autodie; use constant USAGE => <<"EOT"; usage: perl $0 file_in file_zero file_one where: file_in input file name file_zero output file name - address[0] bit == 0 file_one output file name - address[0] bit == 1 EOT die USAGE if @ARGV != 3; my ($file_in, $file_zero, $file_one) = @ARGV; my $rx_cmd_rw = qr{ cmd:SDP_CMD_ (?: RDBLKL | WRSIZEDFULL) }xms; open my $fh_in, '<', $file_in; open my $fh_0, '>', $file_zero; open my $fh_1, '>', $file_one; my $fh_current; LINE: while (my $line = <$fh_in>) { next LINE unless $line =~ m{ \S }xms; # ignore blank lines my $got_cmd_addr = my ($cmd_addr_in_hex) = $line =~ m{ $rx_cmd_rw .*? addr:0x ([[:xdigit:]]+) }xms; if ($got_cmd_addr) { $fh_current = 0x1 & hex $cmd_addr_in_hex ? $fh_1 : $fh_0; } die "no command read/write address seen" unless $fh_current; print $fh_current $line; } close $fh_in; close $fh_0; close $fh_1; exit; # subroutines ###################################################### # none for now