in reply to Perl split on regex match

You could do it all with a regex, a bit like this...

use strict; use warnings; while (<DATA>) { print unless /[^,]+,\d+,([^.]+\.){2}[^,.]+/; } __DATA__ cls1,37,Media.vdenc.abcunit,media_vd cls2,7,Media.Wigig.plsunit,media_vd cls3,27,Media.vdenc,media_vd cls4,47,Media.hevc,media_vd cls5,57,Media.ENC,media_vd

Output

cls3,27,Media.vdenc,media_vd cls4,47,Media.hevc,media_vd cls5,57,Media.ENC,media_vd

Though that is not the most readable way :)

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Replies are listed 'Best First'.
Re^2: Perl split on regex match
by AnomalousMonk (Archbishop) on Jan 03, 2017 at 17:51 UTC
    ... that is not the most readable way ...

    Yea and amen to that, brother!


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