Similar language features to compare with Perl and Ruby __END__
Question
Background
Perl and Ruby have the __END__
and __DATA__
tokens that allow embedding of arbitrary data directly inside a source code file.
Although this practice may not be well-advised for general-purpose programming use, it is pretty useful for "one-off" quick scripts for routine tasks.
Question:
What other programming languages support this same or similar feature, and how do they do it?
Solution
Perl supports the __DATA__
marker, which you can access the contents of as though it were a regular file handle.
OTHER TIPS
Fortran has a DATA statement that sounds like what you're looking for.
Basic on the VIC20 and C64 had a "Data" command that worked something like this
100 DATA 1,2,3
110 DATA 4,5,6
Data could be read via a READ command.
I no longer have a c64 to test my code on.
SAS has the datalines
construct which is used for embedding an external data file inside the source program, e.g. in the following program, there are 5 datalines (the terminator is the semi-colon on a line by itself)
data output;
input name $ age;
datalines;
Jim 14
Sarah 11
Hannah 9
Ben 9
Timothy 4
;
run;