Hi Monks,

Is there ever a difference in semantics between

sub foo {
    ....
    my $value = <expression>;
    return $value;
}

and

sub foo {
    ....
    return <expression>;
}

?

I ask this because I am experiencing a negative interaction between the Komodo remote debugger and the CPAN module DBIx::transaction. When debugging code that commits a transaction, I get an error like this:

panic: attempt to copy freed scalar 350d010 to 15c7b68 at
/usr/share/komodo/perllib/perl5db.pl line 4341, <STDIN> line 1.

Strangely, I have found that I can fix the error by changing the definition of close_transaction in DBIx/Transaction/db.pm from

sub close_transaction {
    my $self = shift;
    my $method = shift;
    my $code = DBI::db->can($method);
    $self->{private_DBIx_Transaction_Level} = 0;
    $self->clear_transaction_error;
    $self->transaction_trace($method);
    my $rv = $code->($self, @_);
    return $rv;
}

to

sub close_transaction {
    my $self = shift;
    my $method = shift;
    my $code = DBI::db->can($method);
    $self->{private_DBIx_Transaction_Level} = 0;
    $self->clear_transaction_error;
    $self->transaction_trace($method);
    return $code->($self, @_);
}

to me, it looks like my change should have no effect, and yet it eliminates the panic. What's going on here? Could it be a bug in the Komodo remote debugging libraries, or in the Perl implementation, or in DBIx::Transaction?

Thanks

In reply to Attempt to copy freed scalar and return value semantics by turkanis

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.