Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl split on regex match

by Random_Walk (Prior)
on Jan 03, 2017 at 08:33 UTC ( [id://1178829]=note: print w/replies, xml ) Need Help??


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:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1178829]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-23 14:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found