in reply to confusing fork/readline behaviour

<quote>as they don't share a file pointer </quote>

Actually for reading they do share the same file descriptor. Try moving that open after the fork().

perl -e ' fork(); open X, "</etc/passwd"; while (readline(X)){ print "$$: $_"; sleep 1 } print "$$: all done\n" '
--
“For the Present is the point at which time touches eternity.” - CS Lewis