Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by Skeeve (Parson)
on Feb 19, 2019 at 10:46 UTC ( #1230158=note: print w/replies, xml ) Need Help??


in reply to Re^6: How can I read DATA in parent and child?
in thread How can I read DATA in parent and child?

What' even weirder: If I run a sequential verison of the same script, the result is, at least in the last 12104 runs, always correct.

So it's not in the code it must have to do with perl itself.

This is the "serialized" code I used:

#!/usr/bin/perl use IO::Handle; use strict; use warnings; my $pos= tell *DATA; my $x= IO::Handle->new(); $x->fdopen(fileno(DATA), "r"); seek $x, $pos, 0; print "Start c $pos\n"; #sleep 4; while (<$x>) { print "c: $_"; #sleep 1; } print "stop c\n"; my $y= IO::Handle->new(); $y->fdopen(fileno(DATA), "r"); seek $y, $pos, 0; print "Start p $pos\n"; while (<$y>) { print "p: $_"; #sleep 1; } print "stop p\n"; __DATA__ a b c d e

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Replies are listed 'Best First'.
Re^8: How can I read DATA in parent and child?
by tybalt89 (Monsignor) on Feb 20, 2019 at 10:33 UTC

    It's not perl, it's the OS. You'd have the same problem with an already open fd in C. DATA is just an open fd on the source file.

    Try a seek DATA, 0, 0; and notice you can read the whole source file.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2022-09-25 17:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (116 votes). Check out past polls.

    Notices?