http://www.perlmonks.org?node_id=1006699


in reply to split a line by control ^D character

The problem is that the chr(4) inside your /chr(4)/ regex is not being interpreted as a function call; rather it is being interpreted literally, with the parens in chr(4) being interpreted as regex metacharacters to capture the 4 in a matching chr4, for example!

There are a number of ways to fix this, for example:

@LineDetails = split /\04/, $line; # ... or @LineDetails = split chr(4), $line;