Thread Fortlaufende Nummer in der pm-Datei selbst
(37 answers)
Opened by rosti at 2013-12-31 18:25
Ok, hier das Script in voller Länge:
Und die ausführliche Fehlerausgabe: Code: (dl
)
1 Number.pm did not return a true value at D:\home\netsh100633\html\cgi-bin\number.pl line 2. Das Modul auch nochmal: 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 package Number; use strict; use warnings; use IO::File; use Fcntl ':flock'; sub new{ my $class = shift; my $self = bless{}, $class; return eval{ my $file = $class.".pm"; $self->{POS} = tell DATA; $self->{BUF} = ''; $self->{FH} = new IO::File; $self->{FH}->open($INC{$file}, O_RDWR) or die "IO-Error: $!"; flock $self->{FH}, LOCK_EX or warn "Your system does not support flock"; $self->{FH}->seek($self->{POS}, 0); read $self->{FH}, $self->{BUF}, 32; $self->{NR} = unpack "A32", $self->{BUF}; $self; }; } sub nr{ my $self = shift; return $self->{NR}++; } sub DESTROY{ my $self = shift; $self->{FH}->seek($self->{POS}, 0); $self->{FH}->print(pack "A32", $self->{NR}); } 1; __DATA__ 2056 Und das Script was vorher gestartet wurde: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 #!/usr/bin/perl use strict; use warnings; use Number; my $no = new Number; sleep 100; Last edited: 2013-01-01 20:39:50 +0100 (CET) |