What does <DATA> mean in Perl error messages?

enter image description here

I am trying to debug the error I am currently experiencing in Perl and my first clues are the files and lines specified. However I am not sure what DATA is .

So what is it?

+3


source to share


2 answers


This means that you read 228 lines from the file descriptor DATA

when the error occurred. In this case, it is unlikely to be relevant.



It is less likely to matter if the descriptor in question is DATA

. DATA

allows the program to read data from the end of the source file. It is usually used to store hard-coded data or part of the program itself. It is usually read from start to finish at the start of a program. But few are worried about closing the handle, so an unrelated error message is flagged with the last line number of that data.

+4


source


<DATA>

is the default file descriptor for tokens __DATA__

or __END__

in Perl.

What does this mean, there should be sections __DATA__

or __END__

towards the end of the running perl script. Regardless of the text you have after these tokens, the perl interpreter is treated as a file and is made available to the program via the file descriptor <DATA>

.



print while (<DATA>); 
# End of Perl script. Whatever follows goes into <DATA> fh. 

__DATA__
line 1
line 2
line 3
line 4
line 5
line 6

      

+1


source







All Articles