
mhassan
Novice
Jan 18, 2010, 11:06 AM
Post #1 of 3
(1691 views)
|
|
Doesn't want to split at 4th occurrence
|
Can't Post
|
|
Hi, I am trying to use split function to split "inbound 2242325546 15 [18/Jan/2010:10:14:27 -0500] 6177123999x1892 000022;015;1263826563 1263827667 1263827710 0:43 ". This is the first line from the test.txt. But I don't want to split at 4th space. Any ideas? So the array should be like.. 1. inbound 2. 2242325546 3. 15 4. [18/Jan/2010:10:14:27 -0500] 5. 6177123999x1892 6. 000022;015;1263826563 7. 1263827667 8. 1263827710 9. 0:43
open(FH,"test.txt"); while(<FH>) { chomp; my @line_array = split(' '); foreach (@line_array) { print $_ . "\n"; } print OFH join('\t',@line_array); }
|