Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How can I read DATA in parent and child?

by choroba (Cardinal)
on Feb 18, 2019 at 14:13 UTC ( [id://1230105]=note: print w/replies, xml ) Need Help??


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]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1230105]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found