Skip to content

Instantly share code, notes, and snippets.

@dmanto
Created April 26, 2019 20:59
Show Gist options
  • Save dmanto/cafcfdf5f0d1568ebe90648bdfa95824 to your computer and use it in GitHub Desktop.
Save dmanto/cafcfdf5f0d1568ebe90648bdfa95824 to your computer and use it in GitHub Desktop.
Problems loading from __DATA__ section with Mojo::Loader
use strict;
use warnings;
use v5.10;
# this script should never give you the "Error (undef)" line.
# however, and depending on where you run it, you will get it time to time.
# For instance, running this on my macbook (perl 5.28.1, Mojolicious 8.14):
#
# $> for i in {1..20};do perl ldtest.pl;done
# # 3: Error (undef)
# # 2: Error (undef)
# # 1: Error (undef)
# # 5: Error (undef)
# # 3: Error (undef)
# # 2: Error (undef)
# # 3: Error (undef)
# # 2: Error (undef)
# # 2: Error (undef)
# # 3: Error (undef)
# # 2: Error (undef)
# $>
use Mojo::Loader qw /data_section/;
for my $i (1 .. 6) {
next if fork;
say "# $i: Error (undef)" unless defined data_section('main', 'myfile');
exit(0);
}
wait();
__DATA__
@@ myfile
some data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment