Leser: 17
1 2 3 4 5 6 7 8 9 10
use strict; use warnings; my $date = $ARGV[0]; # Datum als Befehlsparameter einlesen fuer leichteres testen my $faulty = $date; $faulty =~ s/^20[1-9][0-9]//; $faulty =~ s/0[1-9]|1[012]$//; print "$date\n$faulty\n";
2010-06-11T07:37:38 reneeJa, soweit ich weiß, kann \d noch mehr matchen.
1 2 3 4 5
for (0..255) { if (chr($_) =~ /\d/) { print "$_ " . chr($_) . " match\n"; } }
1
2
3
4
5
6
7
8
9
10
48 0 match
49 1 match
50 2 match
51 3 match
52 4 match
53 5 match
54 6 match
55 7 match
56 8 match
57 9 match
1
2
3
4
5
6
7
8
my $date = '201006';
my $year = substr $date, 0, 4;
my $date = substr $date, 4, 2;
if ($year > 2099 || $year < 2000) {
die "Year out of range. Got $year, expected 2000..2099\n";
}
...
die "Invalid date format\n" unless $date =~ /\A[0-9]{6}\z/;