I have a CSV file with text in them which has new line breaks in it. For example
1,b,hello
world,x
2,a,hello
mars,y
To read it all in a row at a time, I would like to specify a regular expression for the $/ special variable. Any suggestions on how I could do it?
My thinking is, if I put in something like “(x|y)\n” for my special variable it should capture the cases where the line ends with an x or y along with a new line.
Thanks
You can’t use a regex for $/. However, if the file isn’t too big, you can read the whole thing into a scalar and split on the regex.
@records = split /(x|y)\n/, $data;