Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Version list with min and max

by hipowls (Curate)
on Feb 23, 2008 at 01:54 UTC ( [id://669702]=note: print w/replies, xml ) Need Help??


in reply to Version list with min and max

Assuming the individual numbers are in the range 0 - 255 then you can do this

my $min = canonical('2.0.0.0'); my $max = canonical('3.0.0.0'); my @versions = qw(1.0.0.0 1.1.10.1 3.1 2.0.1 1.9.9.9.9 3.0.0.0.0.0.0.1 + 2.9 2.0.0.0 2.1.0.0 10.6.1.0); foreach my $version ( @versions) { my $canonical = canonical($version); print "$version\n" if ( $min le $canonical && $canonical le $max ) +; } sub canonical { return pack 'C*', split /\./, $_[0]; } __END__ 2.0.1 2.9 2.0.0.0 2.1.0.0

Update: removed assumption that the version strings need to have the same number of numbers.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-20 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found