Thread Bei Abfrage des Rückgabewerts aus einer Subroutine gibts Fehler...
(23 answers)
Opened by Brenner at 2009-01-22 12:26
Hauptprogramm:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #! /usr/bin/perl use strict; use warnings; use vars qw(@ISA @EXPORT $VERSION); # include MODUL in module search path BEGIN { push(@INC,"Z:/test"); } use test::log; my @XLOGVALUES001; my $XLOGVALUES001; while(@XLOGVALUES001) { shift(@XLOGVALUES001); } $XLOGVALUES001[0] = "1"; #logfile schreiben: ja = 1 nein = 2 $XLOGVALUES001[1] = "logfile"; #name des logfiles: "logfile.txt" $XLOGVALUES001[2] = 'C:\WINNT\system32\config'; #pfad des logfiles: &test::log::logfilename(\@XLOGVALUES001); $log2 = test::log->logfilename(); print "Zurueckgegebener Wert von der subroutine: ".$log2; Subroutine: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 package test::log; use strict; use warnings; $test::log::VERSION = "0.0.1"; #============================================================================ ## @cmethod # The default constructor of class test::log #============================================================================ sub new { my $this=shift; my $class=ref($this) || $this; my $self= {}; #class attributes $self->{attr1}=undef; #bless the object bless($self,$class); #return the reference to the blesses object return($self); } sub logfilename { my $self = shift; my $logfilename; if (ref $self eq 'ARRAY' and $self->[1]) { $logfilename = ($self->[1]); } else { $logfilename = "DEFAULT_logfile_name"; } return $logfilename; } 1; |