in reply to Capitalized subroutine names and packages

It prints Foo's constructor called, because of the following circumstances (and that's my interpretation) :

  1. The executed code lives in package main and there is a sub named Bar
  2. That sub returns a string, Foo
  3. That string result is then taken as the package name in which to call new()

To circumvent this problem, either make it that [Pp]erl dosen't see Bar as a function name :

print "Bar"->new(), "\n"; # Calls Bar::new()

or call Bar::new() manually, and specify the wanted class name on the parameter list :

my $bar = Bar::new("Bar");

I don't know where in the documentation to look to find some text on this behaviour, but most likely one of the elder Perl users can explain the sequence of events from the documentation (or correct my sequence).

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web