[rt-users] Couldn't compile CustomCommitCode codeblock ... panic: sv_setpvn called with negative strlen -2 at /usr/share/perl5/Devel/StackTrace.pm line 53.
Kevin Falcone
falcone at bestpractical.com
Wed Aug 6 13:04:44 EDT 2014
On Wed, Aug 06, 2014 at 12:46:17PM -0400, Michael Mol wrote:
> First attempt at writing an RT scrip, and I'm getting a compile error
> I can't easily identify as a problem with my code. Googling around
> finds "sv_setpvn called with negative strlen -2" in multiple results,
> but none of them in StackTrace.pm, mostly a lot of stuff surrounding
> Unicode.
You've panic'ed perl.
I assume you're on mod_perl.
> ## Begin code snippet
> # Find the message from transactionobj->content
> # Set the subject to the message by using ticketobj->SetSubject
>
> my $body = $self->TransactionObj->Content;
>
> open my $fh '<', \$body or return 0;
>
> my $trapID = <$fh>; chomp $trapID;
> <$fh>;
> my $messageLine = <$fh>; chomp $messageLine;
>
> $self->TicketObj->SetSubject("$trapID -- $messageLine);
>
> close $fh;
Why are you turning a perfectly good string into a file handle just to
read three lines? Split it on newlines or write a regexp.
-kevin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 235 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20140806/ecd391ad/attachment.sig>
More information about the rt-users
mailing list