Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Comparing decimal values

by blokhead (Monsignor)
on Jan 21, 2003 at 15:42 UTC ( [id://228714]=note: print w/replies, xml ) Need Help??


in reply to Comparing decimal values

You have to split the version numbers into pieces and compare each part. Here's a very wordy solution:
my $old_version = '1.4.10'; my $new_version = '1.6.0'; my @old_version = split /\./, $old_version; my @new_version = split /\./, $new_version; my $cmp = 0; $cmp ||= ($old_version[$_] <=> $new_version[$_]) for (0 .. $#old_versi +on); if ($cmp == 0) { print "$old_version == $new_version\n"; } elsif ($cmp == 1) { print "$old_version > $new_version\n"; } else { print "$old_version < $new_version\n"; }

blokhead

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://228714]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found