Skip to content

Instantly share code, notes, and snippets.

@xtetsuji
Created October 3, 2012 09:16
Show Gist options
  • Save xtetsuji/3825975 to your computer and use it in GitHub Desktop.
Save xtetsuji/3825975 to your computer and use it in GitHub Desktop.
Emulate __DATA__ section for mod_perl Registry/PerlRun script, and so on.
#!/usr/bin/perl
# Emulate __DATA__ section for mod_perl Registry/PerlRun script, and so on.
use strict;
use warnings;
### In tail of this file, its "data" exists and defines inside BEGIN { ... } block.
my $DATA;
open \*DATA, '<', \$DATA;
### can I read fake DATA filehandle?
while (<DATA>) {
print "DUMMY_DATA_SECTION: $_";
}
BEGIN { $DATA = <<__FAKE_DATA__; }
Hello! Data!
This is emulate DATA section.
This way can be used on mod_perl!
__FAKE_DATA__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment