package Datum; use base qw( Exporter ); our EXPORT = qw (); sub new { # neue Instanz erzeugen my $class = shift; $class = ref($class) if ref($class); # Datumswerte werden einzeln gespeichert my $self = { year => 0, month => 0, day => 0, }; bless $self, $class; return $self; } sub set { # Datumswerte setzen # Parameter-Reihenfolge nach ISO my $self = shift; my ($y, $m, $d) = @_; $self->{year} = $y; $self->{month} = $m; $self->{day} = $d; } sub dateformat { # Datumsformat der Klasse liefern return "%y-%m-%d"; } sub get { # Datum abfragen # ISO-Format my $self = shift; my $date = $self->dateformat(); $date =~ s/%y/$self->{year}/g; $date =~ s/%m/$self->{month}/g; $date =~ s/%d/$self->{day}/g; return $date; } sub tounixtime { my $self = shift; my $unixtime = ... return $unixtime; } sub print { my $self = shift; print $self->get(); } 1; package Datum::DE; use base qw( Datum ); sub dateformat { return "%m/%d/%y"; } 1; package Datum::US; use base qw( Datum ); sub dateformat { return "%d.%m.%y"; } 1; package main; my $gerdate = new Datum::DE(2003, 10, 2); $gerdate->print(); my $usdate = new Datum::US(2003, 10, 2); $usdate->print();