Keep It Simple, Stupid | |
PerlMonks |
Re: Sorting on Section Numbersby acme (Novice) |
on Jul 28, 2000 at 18:48 UTC ( [id://24858]=note: print w/replies, xml ) | Need Help?? |
Of course, there is a module on CPAN which does what you want! It's called Sort::Versions, available from http://search.cpan.org/search?dist=SortVersions and it basically does what you want:
#!/usr/local/bin/perl use strict; use Sort::Versions; my @sections = qw(2.1.7 2.2 3.4a 2.13 1 2); @sections = sort versions @sections; print "@sections\n"; # prints "1 2 2.1.7 2.2 2.13 3.4a"Hope this helps! Leon
In Section
Seekers of Perl Wisdom
|
|