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; 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 the other modules are quite similar. The only difference is that they don't use the exporter... What I've found is the following:#!/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...
In reply to Warning: Freeing unreferenced scalar by mck
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |