Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How can I read a file that is comma delimited but includes a comma in the string?

by Skeeve (Vicar)
on May 28, 2003 at 06:54 UTC ( #261238=note: print w/ replies, xml ) Need Help??


in reply to How can I read a file that is comma delimited but includes a comma in the string?

If these conditions are met:

  1. There are always 5 Fields
  2. Additional commas only appear in the fifth field
  3. then this code will give you the desired result:
    while ($line=<DATA>) { chomp $line; ($char, $num1, $num2, $num3, $commafield)=split(/,/,$line,5); print <<MYDATA; $char $num1 $num2 $num3 $commafield ------- MYDATA } __DATA__ R,2164,27-2164,270102,Add Terminal Server to John, Jane, and Georges $,1111,22-2222,333333,Ignore mails from support, microsoft or bill


Comment on Re: How can I read a file that is comma delimited but includes a comma in the string?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-12-29 07:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls