Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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: (9)
As of 2015-07-03 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls