Thanks ikegami but I'm still not quite understanding this but I certainly appreciate your help. In your example you've used $x for the "workaround". I don't understand why I have to do this. Perhaps it would be easier if I posted the exact code (comments labelled MJE I added):

sub queue_job { my ($betdb, $q, $job) = @_; my $key; $job->{jobid} = new_job_id($betdb); # MJE - obviously this can be undef but in the case in # question it is usually set my $clientref = $job->{clientref} if (exists($job->{clientref})); # # Insert info about this job in the audit file. # NOTE: This will fail if we've seen this client_reference before +as # client_reference is unique and it would indicate a client has su +bmitted # the same job twice e.g. posted the same job twice. # my $caught = try { my $repost = $clientref ? 0 : undef; $betdb->execProc( $p_run_or_queue_job, {DieOnError => 1, Comment => 'queue_job'}, $job->{jobid}, $clientref, $job->{sessionid}, $job->{name}, {clob => $json->objToData($job)}, $repost, 1); 0; } catch { my $ev = $_; if (($betdb->getDBh())->err == 1) { # constraint violation eval { $betdb->callPkgProc( {DieOnError => 1, Comment => 'run_now'}, BET::DB::SYN_PKG_BETDB, 'p_invalidJobRequest', $job->{jobid}, $clientref, $job->{sessionid}, $job->{name}, $json->objToData($job->{args}), R_DIE, "Job already seen"); 1; } or $log->warn("Failed to mark job already seen - $@"); $job->{joberr} = 'Already seen this job'; $job->{jobnative} = c_JOB_ALREADY_SEEN; $log->warn(sub {'JOB ALREADY POSTED ' . Dumper($job)}); } else { $log->logwarn("Failed to insert into job_audit, $ev"); } 1; }; return if $caught; my @now = gmtime(time()); $job->{jobqed} = sprintf "%d/%d/%d %02d:%02d:%02d", $now[3], $now[4]+1, $now[5]+1900, $now[2], $now[1], $now[0]; push @{$q->{jobs}}, $job; $q->{queued}->{$key} = $job->{jobid} if ($key); $log->debug("Queued job " . $job->{jobid}); $total_jobs_on_all_queues++; return $job->{jobid}; }

$clientref if the scalar which 5.10.1 complains about.


In reply to Re^6: panic: attempt to copy freed scalar a7b9650 to ad20598 by mje
in thread panic: attempt to copy freed scalar a7b9650 to ad20598 by mje

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.