Thread Timestamp Dateien abfragen (13 answers)
Opened by leissi at 2005-12-14 15:11

J-jayz-Z
 2005-12-14 19:33
#60902 #60902
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Ich hab da mal ne Funktion geschrieben, vielleicht hilft sie dir:
Code: (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
sub mtime {
my $file = shift;
my $option = shift;
my $mtime = (stat $file)[9];
my $epoch = time();
my $mtime = $epoch-$atime;

if($option eq "time") {
if($mtime < 60) {
my $sek = $mtime % 60;
$mtime = $sek . " sec";
} elsif($mtime >= 60 && $mtime < 3600) {
my $min = $mtime / 60 % 60;
my $sek = $mtime % 60;
$mtime = $min.":".$sek . " min";
} else {
my $hour = $mtime / 3600 % 60;
my $min = $mtime / 60 % 60;
my $sek = $mtime % 60;
$mtime = $hour.":".$min.":".$sek . " hour";
}
} elsif ($option eq "date") {
$mtime = scalar localtime $mtime;
}
}
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de

View full thread Timestamp Dateien abfragen