in reply to Re^2: How to test for a new line
in thread How to test for a new line
You should have specified that in your original question. "... to be sure they only have new lines" is not the same as "give a understanable error to the user." Now then, here's how i might check for such an "error":
When you slurp a filehandle into an array, you can always count the number of lines by counting how many elements the array has. No need to explicitly check for newlines.my @array = <FILEHANDLE>; if (@array < 1) { # we have no lines, send an error message } eslif (@array > 1) { # we have a 'too many lines' error jim, send a message } else { # this porridge tastes *just* right ... continue with processing }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|