Quantcast
Channel: alvinalexander.com - data
Viewing all articles
Browse latest Browse all 25

Put Perl test data in the same file as your source code

$
0
0

Perl test data FAQ: How can I store some sample/test data with my source code in Perl?

Answer: With Perl it's very easy to store some sample data in the same file as your Perl source code. Assuming you're creating a "main" Perl program (not a Perl module) you can use the special __END__ operator, and then include your data after that operator, as shown in my sample code below. You can then access that data using the main::DATA operator inside of a while loop.

Here's a quick sample program:

read more


Viewing all articles
Browse latest Browse all 25

Trending Articles