Try this. Note that:

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


Give a man a fish:  <%-{-{-{-<


In reply to Re^3: Print multiple lines based on condition by AnomalousMonk
in thread Print multiple lines based on condition by syedasadali95

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.