http://qs321.pair.com?node_id=1230105


in reply to How can I read DATA in parent and child?

Interesting. Even duplicating the DATA handle in the child doesn't help.
open my $d2, '<&', *DATA or die $!;

But opening the script itself again works, using tell to find the position of the DATA section:

#!/usr/bin/perl use warnings; use strict; open my $d2, '<', $0 or die $!; seek $d2, tell *DATA, 0; if (fork) { while (<DATA>) { print "parent: $_"; } } else { while (<$d2>) { print "child: $_"; } exit } __DATA__ a b c
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]