Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Perl split on regex match

by Random_Walk (Prior)
on Jan 03, 2017 at 08:33 UTC ( #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 (Bishop) 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
Node Status?
node history
Node Type: note [id://1178829]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2021-04-17 08:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?