your solution is correct. Passing in the $kiosk object makes it accessible to the message handler routine

print "INSTANTIATING KIOSK ==============================\n"; my $kiosk = Kiosk->new($placard, $server, $debug_level); # start the server on port __ print "INSTANTIATING SERVER port $kiosk_port ========================= +=====\n"; my $server = MyWebServer->new($kiosk_port); $server->run(); $server->{kiosk} = $kiosk;

this part in HTTP::Server::Simple::CGI; sees it just fine and responds properly ... so THANK YOU.

sub handle_request { my $self = shift; my $cgi = shift; my $json_string = $cgi->param('POSTDATA'); # { "type":"cardCheck", "date":"1482307795601", "lang": "EN", +"machineName":"PLUSMAKM", "cardNumber":"1234567890", "PIN": "1234" } print "json_string=$json_string\n"; $json_dict = decode_json $json_string; print "json_dict=" . Dumper($json_dict) . "\n"; my $response = $self->{kiosk}->process($json_dict); print "response=$response\n"; return $response; }

there was one issue in fully implementing your solution (the code worked without it). When you add the "new" method to HTTP::Server::Simple::CGI;object as follows you get an execution error

sub new { my $self = {}; $self->{class} = $class; $self->{kiosk} = undef; bless($self,$class); return $self; }

Can't locate object method "run" via package "main" at http_server.pl line 56, <CONF> line 35. line 56 is

$server->run();

this was the original reason I requested help. Now that I see the code a bit more I guess the question is "how do you exend the HTTP::Server::Simple::CGI; object, but that is another topic. SO I thank you for an excelent easy solution and, if you have any ideas about the ast question, I would love to hear it so I can gain more knowledge about OO in Perl.


In reply to Re^2: Mass Class Confusion - Who calls what how? by holandes777
in thread Mass Class Confusion - Who calls what how? by holandes777

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.