Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- in my on recv for a websocket..
- #I create a hash with the json structure.
- my $json = JSON->new->allow_nonref;
- my %req = %{ $json->decode( $msg ) };
- #verify it works and hash is created, all data elements are there..
- while (my ($k,$v)=each %req)
- {
- app->log->debug(sprintf 'JSON: %s : %s', $k, $v);
- }
- #now I want to either perform inserts into database or updates to database.. so I send it off to a helper
- $self->upsert(\%req);
- ...
- helper upsert => sub
- {
- my $self = shift;
- my %req = %_;
- app->log->debug(sprintf 'UPSERT Called');
- while (my ($k,$v)=each %req)
- {
- app->log->debug(sprintf 'UPSERT: %s : %s', $k, $v);
- }
- #do something useful with hash once I verify it is sane
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement