⭐ in reply to How do I read the contents of a file?
You can also change the record separator. The record separator is the character that perl uses to decide how much data to take in at once.
It is accessed with the special variable $/ and the default value is \n.
Some examples:
prints:$/ = "\n"; #default value $file=<DATA>; #gets one line @file=<DATA>; #gets all lines, each line in one value print "$file\n\n"; print join "|", @file; __DATA__ 1,2,3 4,5,6 7,8,9
While but if you set $/ = ","; you get:1,2,3 4,5,6 |7,8,9
Note that in the second example, "3\n4," is a record.1, 2,|3 4,|5,|6 7,|8,|9
|
|---|