An update (as a new post to avoid confusion):

It took a while but eventually it sank in: Ma and the AM who wrote Split Tab separated text file into valid and invalid records (presumed to be the same person) asked two quite distinct questions. My past node replied to the AM, whilst ignoring the specs in the top node.

So (JBIC & because I have time-on-my-hands awaiting a particular event), herewith, a solution that satisfies both (I think) in one (didactic) script:

#!/usr/bin/perl use strict; use warnings; # 1055276 (see also my splitTOscalars.pl) # OP valid: $dt (AKA 'name')is alpha , datefield using slashes, balanc +edue field is numeric # second post as AM: split problems my ($dt, $account, $baldue); while (<DATA>) { chomp; ($dt, $account, $baldue) = split/\t/; # was: split("\t"); if ($dt =~ /[A-Z]+/i && $account =~ /^[\d\/]+$/ && $baldue =~ /^[\ +d.,]+$/) { print "\n VALID per OP: \$dt: $dt | \$account: $account | \$ba +ldue: $baldue \n\n"; }elsif ($dt =~ /[a-z]+/) { print "Invalid: $dt -|- $account -|- $baldue \n"; }else { print "\nValid per #1055280 \$dt, \$account, \$baldue: $dt, +$account, $baldue\n"; } } =head OUTPUT Valid per #1055280 $dt, $account, $baldue: 4-11-13, 273.13, 273.13 Valid per #1055280 $dt, $account, $baldue: 20130512, 11.17, 36.14 Valid per #1055280 $dt, $account, $baldue: 09222013, 2479.00, 6481.1 +6 VALID per OP: $dt: xyz | $account: 09/30/2013 | $baldue: 500 Invalid: abc -|- 09/30/2013 -|- YYN Invalid: del -|- hfhfh -|- 200 =cut __DATA__ 4-11-13 273.13 273.13 20130512 11.17 36.14 09222013 2479.00 6481.16 xyz 09/30/2013 500 abc 09/30/2013 YYN del hfhfh 200

In reply to Re: Split Tab separated text file into valid and invalid records by ww
in thread Split Tab separated text file into valid and invalid records by Ma

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.