H
hobosalesman
I'm trying to plan out a program and I have a couple questions (which
I've looked up but couldn't find a satisfactory answer for).
1) Is there anything inherently wrong with calling fork() within the
constructor for my object? I'm trying to make a program that works
similar to something like apache, it has a parent that creates many
children which it manages. I have a "child" class which I use to create
child objects something like:
$child = Child->new();
if ($child->(isChild)) {} else {}
The object would know if it were the child by what fork() returns.
2) The children and the parent both need some modules, like DBI, but
some are needed by one but not the other. Is there a problem putting
"use PackageX" for evrey package both processes will need or would that
be wasting resources? Should I maybe do something like:
if ($child->(isChild)) {
require "child libraries";
} else {
require "parent libraries";
}
And then "use PackageX" inside those libraries... will that have the
packages called at run time (not called if not needed) rather than at
compile time as in a normal "use X"? Or is my understanding way short
here?
3) Are there any good books out there on writing these kinds of
programs in perl? This is a web crawler search engine, but I'm
interested in the design aspects of these kinds of programs, which I
suppose aren't language specific. I'm not finding much good information
on managing persistent daemon-style programs or database design for
search engines.
I've looked up but couldn't find a satisfactory answer for).
1) Is there anything inherently wrong with calling fork() within the
constructor for my object? I'm trying to make a program that works
similar to something like apache, it has a parent that creates many
children which it manages. I have a "child" class which I use to create
child objects something like:
$child = Child->new();
if ($child->(isChild)) {} else {}
The object would know if it were the child by what fork() returns.
2) The children and the parent both need some modules, like DBI, but
some are needed by one but not the other. Is there a problem putting
"use PackageX" for evrey package both processes will need or would that
be wasting resources? Should I maybe do something like:
if ($child->(isChild)) {
require "child libraries";
} else {
require "parent libraries";
}
And then "use PackageX" inside those libraries... will that have the
packages called at run time (not called if not needed) rather than at
compile time as in a normal "use X"? Or is my understanding way short
here?
3) Are there any good books out there on writing these kinds of
programs in perl? This is a web crawler search engine, but I'm
interested in the design aspects of these kinds of programs, which I
suppose aren't language specific. I'm not finding much good information
on managing persistent daemon-style programs or database design for
search engines.