So basically I want only the first four command separated fields and strip off the rest. How do I do it in perl?
I want only perl code and no shell code.
I can split it and try to do something, but the incoming data can have any number of comma separated fields so was thinking of a more better solution.
I changed the + in durden tyler's suggestion from + (1 or more) to * (0 or more). It means keep 0 or more occurrences of any character but a comma ( [^,] ) followed by 3 times: the combination of a comma followed by 0 or more occurrences of any character but a comma . This is stored in back reference $1. Replace all this and the rest of the line (.*) by $1 which contains what was previously stored...
I changed the + in durden tyler's suggestion from + (1 or more) to * (0 or more). It means keep 0 or more occurrences of any character but a comma ( [^,] ) followed by 3 times: the combination of a comma followed by 0 or more occurrences of any character but a comma . This is stored in $1. Replace all this and the rest of the line (.*) by $1 which contains what was previously stored...