diff options
| -rw-r--r-- | challenge-058/yet-ebreo/perl/ch-1.pl | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/challenge-058/yet-ebreo/perl/ch-1.pl b/challenge-058/yet-ebreo/perl/ch-1.pl index 7aa7c804ae..2a305c4b8b 100644 --- a/challenge-058/yet-ebreo/perl/ch-1.pl +++ b/challenge-058/yet-ebreo/perl/ch-1.pl @@ -4,20 +4,20 @@ use warnings; use feature 'say'; sub compare { - $_[0] =~ s/[._]0+$//r =~s/_/!/gr =~ s/\d+/0|$&/gre - cmp - $_[1] =~ s/[._]0+$//r =~s/_/!/gr =~ s/\d+/0|$&/gre; + 0+eval "@_"=~s/\S+/\"$&\"/gr =~s/ / cmp /r =~ s/[._]0+\"/\"/gr =~s/_/!/gr =~ s/\d+/sprintf "%09d",$&/gre; } -my @num_set = ( - [qw(0.1 1.1)], - [qw(2.0 1.2)], +my @num_set = ( + [qw(0.1 1.1)], + [qw(2.0 1.2)], [qw(1.2 1.2_5)], [qw(1.2.1 1.2_1)], [qw(1.2.1 1.2.1)], - [qw(3_3 3.3)], + [qw(3_3 3.3)], [qw(1.01.1 1.1.1)], - [qw(2_0 2.0)], + [qw(2_0 2.0)], + [qw(1.9 1.10)], + [qw(1.002 1.2)] ); #Notes: @@ -25,7 +25,7 @@ my @num_set = ( # - 2_00 , 2.0 and 2 are considered equal for my $num (@num_set) { my $c = compare(@{$num}); - printf "%10s %s %-10s %2s\n", $num->[0], qw(< = >)[$c+1], $num->[1], $c ; + printf "%10s %s %-10s %2s\n", $num->[0], qw(< = >)[$c+1], $num->[1], $c; } =begin @@ -38,4 +38,6 @@ perl .\ch-1.pl 3_3 < 3.3 -1 1.01.1 = 1.1.1 0 2_0 = 2.0 0 + 1.9 < 1.10 -1 + 1.002 = 1.2 0 =cut
\ No newline at end of file |
