Dignified Monks,

I have a script that works fine under windows and Activeperl 5.10.
It has to be portable to AIX, this is the IBM-Unix derivate, on which the version 5.8.2 is currently running. The script I wrote converts a textfile into another textfile. The script says:
Attempt to free unreferenced scalar: SV 0x302611d0 at ./avp2unit.pl line 7.
Attempt to free unreferenced scalar: SV 0x3027a8ec at ./avp2unit.pl line 8.
Attempt to free unreferenced scalar: SV 0x303c4948 at OutputWriter.pm line 9.
Attempt to free unreferenced scalar: SV 0x303bf310 at OutputWriter.pm line 10.
Attempt to free unreferenced scalar: SV 0x302b7eb4 at ./avp2unit.pl line 9.
And here is my avp2unit.pl-code
#!/usr/bin/perl use v5.8.2; # Use the version which is on the AIX machines use strict; use bigint; use File::Basename; use lib File::Basename::dirname($0); # find .pm files in script's di +r use FunctionsAPI; #<--- line 7. These are my modules... use DataObject; #<--- line 8 use OutputWriter; #<--- line 9 #main { my $argc = @ARGV; if($argc < 1){ die( drawError("Insufficient Parameters", "One or two paramete +rs are needed.")); } my $inputfilename = $ARGV[0]; open(my $AVPFILE, $inputfilename) or die( drawError("Unable to ope +n file $ARGV[0]", "Unfortunatelly, the file: $ARGV[0] is not readable +.")); my $shortfilename; if($inputfilename =~ m/^(.*)\.avp$/) { $shortfilename = $1; } else { $shortfilename = $inputfilename; } my $data = new DataObject(); print "Proceeding ".$inputfilename." -->\n"; for(my $loop=0; !eof($AVPFILE); $loop++ ) { $data->readFile($AVPFILE); + # continue to read the Test inside the AVP-File my $writer = manufacture OutputWriter( $data->{MNEMONIC} ); + # Ask the factory to produce e.g. a KMF-moduleWriter with th +e mnemonic B92A if( defined($writer) ) + # don't do anything if the mnemonic is not recognizesed by th +e factory { unless( translationIncompatible($data) || globalWarningIsS +et() ) { my $outputfilename = $shortfilename.".".sprintf("%04i" +,$loop).'.src'; # e.g. $inputname = example.avp -> + $shortfilename = example $writer->writeTest($data, $outputfilename); + # produce the outputfile with th +e name example0001.src unlink($outputfilename) if globalWarningIsSet(); + # delete file if there happend s.th +. really evil print "\tsuccessfully written file: ".$outputfilename. +"\n" unless globalWarningIsSet(); # print that everything went fin +e } } $data->clearData(); } close($AVPFILE); };
And that is what a module of me looks like:
#!/usr/bin/perl use v5.8.2; # Use the version which is on the AIX machines use strict; # Declare strict checking on variable names, etc. use bigint; # Be able to handle 64-bit integers. Unfortunatelly + also floats are truncated to integer, but that's ok because we're no +t using any of them! package FunctionsAPI; require Exporter; our @ISA = "Exporter"; # inherit from the Exporter-Class our @EXPORT = qw(drawError drawWarning whiteTrim leadingWhiteTr +im); # our functions to get exported by default our $VERSION = 0.01; # this is the momentary package + version my ($INITMEM, $RESULTMEM) = ( 0, 1 ); my $globalwarning = 0; sub ... and so on...
and the other modules are quite similar. The only difference is that they don't use the exporter... What I've found is the following:
Attempt to free unreferenced scalar:
(W internal) Perl went to decrement the reference count of a scalar to see if it would go to 0, and discovered that it had already gone to 0 earlier, and should have been freed, and in fact, probably was freed. This could indicate that SvREFCNT_dec() was called too many times, or that SvREFCNT_inc() was called too few times, or that the SV was mortalized when it shouldn't have been, or that memory has been corrupted.

Does this mean it's an internal error of AIX/perl?

I thank you very much for your help. Comments on the code are also welcomed...
sincerely mck

In reply to Warning: Freeing unreferenced scalar by mck

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.