A
Andrew
Hello, all
Over the years, while configuring my local cpan utility I have been a
little frustrated with the part where one picks URLs from a long list.
It seems that the code underutilized the parsing powers of Perl itself,
to make more convenient such a "recursive" utility (Perl configuring
Perl), so yesterday I undertook to enhance FirstTime.pm
My primary objective was to save the user the tedium of typing a large
set of numbers, such as:
3 4 5 6 9 10 11 12 13 14 15 17 20 21 22 23 24 25 26 ... 43
and shrink the above, for instance, to
3-9 10-15 17 20-43
I seem to have accomplished this:
http://www.flight.us/misc/FirstTime.pm_AStrebkov.htm
( feel free to test )
My changes/additions are highlighted in red, and the embarrassing
"ugliness alert" confesses the shortcomings.
(if you try it, be sure to backup your
/usr/lib/perl5/5.8.6/CPAN/Config.pm and then empty it, leaving just a
"1;" therein (to trigger FirstTime); backup your
/usr/lib/perl5/5.8.6/CPAN/FirstTime.pm and replace it with the plain
file linked from the above link)
As a not-that-much-of-a-side note, I am somewhat puzzled by the current
version of FirstTime.pm, which seems to fail to display the subsequent
subsets of items (beyond the first one) when the superset is greater
than the 15-items/per/view limit. In addition, the directive "hit
SPACE ENTER" used to be misleading previously (am I wrong?); hitting
"SPACE ENTER" was the exact equivalent of just hitting ENTER, since the
spaces used to be stripped (not anymore).
I also added the option to view the list of items selected by the user
thus far (induced by typing "show" (+RETURN) )
all in all, this version allows one to continually loop over all the
items, quickly select ranges (several ranges at once), view the
cumulative user-selected list, and does not have what seems to me to be
bugs in the previous (current!
version.
The selected range(s) can exceed the range currently displayed, but not
the overall range of the items. Input ranges can overlap (either
within one or across multiple iterations), as the code condenses the
list down to distinct items.
Would be glad to hear comments and improvement tips.
I am not 100% sure that my version does not break in some special
circumstance.
TIA
andrew
----------------some output below ---------------------
<------- snip --------->
(15) ftp://cpan.uchicago.edu/pub/CPAN/
(16) ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN
45 more items, hit SPACE RETURN to show them
Select as many URLs as you like. Type individual indexes or hyphenated
ranged separated by spaces. E.g., '1 4-10 12 13-15 '.
(Empty input finishes this (URL) section. Type "show" to see your
picks.) [] 1-4 7-10 30-44 55
<------- snip --------->
(29) ftp://ftp.uwsg.iu.edu/pub/perl/CPAN/
(30) ftp://linux.cs.lewisu.edu/pub/CPAN
(31) ftp://mirror.candidhosting.com/pub/CPAN
(32) ftp://mirror.cc.columbia.edu/pub/software/cpan/
29 more items, hit SPACE RETURN to show them
Select as many URLs as you like. Type individual indexes or hyphenated
ranged separated by spaces. E.g., '1 4-10 12 13-15 '.
(Empty input finishes this (URL) section. Type "show" to see your
picks.) [] show
Your picks thus far: (1)ftp://carroll.cac.psu.edu/pub/CPAN/
(2)ftp://cpan-du.viaverio.com/pub/CPAN/
(3)ftp://cpan-sj.viaverio.com/pub/CPAN/
(4)ftp://cpan.calvin.edu/pub/CPAN (7)ftp://cpan.erlbaum.net/CPAN/
(8)ftp://cpan.llarian.net/pub/CPAN/
(9)ftp://cpan.mirrors.redwire.net/pub/CPAN/
(10)ftp://cpan.mirrors.tds.net/pub/CPAN
(30)ftp://mirror.candidhosting.com/pub/CPAN
(31)ftp://mirror.cc.columbia.edu/pub/software/cpan/
(32)ftp://mirror.datapipe.net/pub/CPAN/
(33)ftp://mirror.hiwaay.net/CPAN/
(34)ftp://mirror.sg.depaul.edu/pub/CPAN/
(35)ftp://mirror.sit.wisc.edu/pub/CPAN/
(36)ftp://mirror.xmission.com/CPAN/
(37)ftp://mirrors.ibiblio.org/pub/mirrors/CPAN
(38)ftp://mirrors.jtlnet.com/CPAN/
(39)ftp://mirrors.kernel.org/pub/CPAN
(40)ftp://mirrors.phenominet.com/pub/CPAN/
(41)ftp://mirrors.rcn.net/pub/lang/CPAN/
(42)ftp://perl.secsup.org/pub/perl/ (43)http://cpan-2.mirrors.nks.net/
(44)http://cpan.belfry.net/ (55)http://mirror.uta.edu/CPAN
(17) ftp://ftp-mirror.internap.com/pub/CPAN/
(18)
ftp://ftp.ccs.neu.edu/net/mirrors/ftp.funet.fi/pub/languages/perl/CPAN/
(19) ftp://ftp.cenergynetworks.com/pub/CPAN/
(20) ftp://ftp.cise.ufl.edu/pub/mirrors/CPAN/
(21) ftp://ftp.dc.aleron.net/pub/CPAN/
(22) ftp://ftp.duke.edu/pub/perl/
(23) ftp://ftp.epix.net/pub/languages/perl/
(24) ftp://ftp.mednor.net/pub/mirrors/CPAN/
(25) ftp://ftp.ncsu.edu/pub/mirror/CPAN/
(26) ftp://ftp.osuosl.org/pub/CPAN/
(27) ftp://ftp.saintjoe.edu/pub/CPAN
(28) ftp://ftp.sunsite.utk.edu/pub/CPAN/
(29) ftp://ftp.uwsg.iu.edu/pub/perl/CPAN/
(30) ftp://linux.cs.lewisu.edu/pub/CPAN
(31) ftp://mirror.candidhosting.com/pub/CPAN
(32) ftp://mirror.cc.columbia.edu/pub/software/cpan/
29 more items, hit SPACE RETURN to show them
Select as many URLs as you like. Type individual indexes or hyphenated
ranged separated by spaces. E.g., '1 4-10 12 13-15 '.
(Empty input finishes this (URL) section. Type "show" to see your
picks.) []
Over the years, while configuring my local cpan utility I have been a
little frustrated with the part where one picks URLs from a long list.
It seems that the code underutilized the parsing powers of Perl itself,
to make more convenient such a "recursive" utility (Perl configuring
Perl), so yesterday I undertook to enhance FirstTime.pm
My primary objective was to save the user the tedium of typing a large
set of numbers, such as:
3 4 5 6 9 10 11 12 13 14 15 17 20 21 22 23 24 25 26 ... 43
and shrink the above, for instance, to
3-9 10-15 17 20-43
I seem to have accomplished this:
http://www.flight.us/misc/FirstTime.pm_AStrebkov.htm
( feel free to test )
My changes/additions are highlighted in red, and the embarrassing
"ugliness alert" confesses the shortcomings.
(if you try it, be sure to backup your
/usr/lib/perl5/5.8.6/CPAN/Config.pm and then empty it, leaving just a
"1;" therein (to trigger FirstTime); backup your
/usr/lib/perl5/5.8.6/CPAN/FirstTime.pm and replace it with the plain
file linked from the above link)
As a not-that-much-of-a-side note, I am somewhat puzzled by the current
version of FirstTime.pm, which seems to fail to display the subsequent
subsets of items (beyond the first one) when the superset is greater
than the 15-items/per/view limit. In addition, the directive "hit
SPACE ENTER" used to be misleading previously (am I wrong?); hitting
"SPACE ENTER" was the exact equivalent of just hitting ENTER, since the
spaces used to be stripped (not anymore).
I also added the option to view the list of items selected by the user
thus far (induced by typing "show" (+RETURN) )
all in all, this version allows one to continually loop over all the
items, quickly select ranges (several ranges at once), view the
cumulative user-selected list, and does not have what seems to me to be
bugs in the previous (current!
The selected range(s) can exceed the range currently displayed, but not
the overall range of the items. Input ranges can overlap (either
within one or across multiple iterations), as the code condenses the
list down to distinct items.
Would be glad to hear comments and improvement tips.
I am not 100% sure that my version does not break in some special
circumstance.
TIA
andrew
----------------some output below ---------------------
<------- snip --------->
(15) ftp://cpan.uchicago.edu/pub/CPAN/
(16) ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN
45 more items, hit SPACE RETURN to show them
Select as many URLs as you like. Type individual indexes or hyphenated
ranged separated by spaces. E.g., '1 4-10 12 13-15 '.
(Empty input finishes this (URL) section. Type "show" to see your
picks.) [] 1-4 7-10 30-44 55
<------- snip --------->
(29) ftp://ftp.uwsg.iu.edu/pub/perl/CPAN/
(30) ftp://linux.cs.lewisu.edu/pub/CPAN
(31) ftp://mirror.candidhosting.com/pub/CPAN
(32) ftp://mirror.cc.columbia.edu/pub/software/cpan/
29 more items, hit SPACE RETURN to show them
Select as many URLs as you like. Type individual indexes or hyphenated
ranged separated by spaces. E.g., '1 4-10 12 13-15 '.
(Empty input finishes this (URL) section. Type "show" to see your
picks.) [] show
Your picks thus far: (1)ftp://carroll.cac.psu.edu/pub/CPAN/
(2)ftp://cpan-du.viaverio.com/pub/CPAN/
(3)ftp://cpan-sj.viaverio.com/pub/CPAN/
(4)ftp://cpan.calvin.edu/pub/CPAN (7)ftp://cpan.erlbaum.net/CPAN/
(8)ftp://cpan.llarian.net/pub/CPAN/
(9)ftp://cpan.mirrors.redwire.net/pub/CPAN/
(10)ftp://cpan.mirrors.tds.net/pub/CPAN
(30)ftp://mirror.candidhosting.com/pub/CPAN
(31)ftp://mirror.cc.columbia.edu/pub/software/cpan/
(32)ftp://mirror.datapipe.net/pub/CPAN/
(33)ftp://mirror.hiwaay.net/CPAN/
(34)ftp://mirror.sg.depaul.edu/pub/CPAN/
(35)ftp://mirror.sit.wisc.edu/pub/CPAN/
(36)ftp://mirror.xmission.com/CPAN/
(37)ftp://mirrors.ibiblio.org/pub/mirrors/CPAN
(38)ftp://mirrors.jtlnet.com/CPAN/
(39)ftp://mirrors.kernel.org/pub/CPAN
(40)ftp://mirrors.phenominet.com/pub/CPAN/
(41)ftp://mirrors.rcn.net/pub/lang/CPAN/
(42)ftp://perl.secsup.org/pub/perl/ (43)http://cpan-2.mirrors.nks.net/
(44)http://cpan.belfry.net/ (55)http://mirror.uta.edu/CPAN
(17) ftp://ftp-mirror.internap.com/pub/CPAN/
(18)
ftp://ftp.ccs.neu.edu/net/mirrors/ftp.funet.fi/pub/languages/perl/CPAN/
(19) ftp://ftp.cenergynetworks.com/pub/CPAN/
(20) ftp://ftp.cise.ufl.edu/pub/mirrors/CPAN/
(21) ftp://ftp.dc.aleron.net/pub/CPAN/
(22) ftp://ftp.duke.edu/pub/perl/
(23) ftp://ftp.epix.net/pub/languages/perl/
(24) ftp://ftp.mednor.net/pub/mirrors/CPAN/
(25) ftp://ftp.ncsu.edu/pub/mirror/CPAN/
(26) ftp://ftp.osuosl.org/pub/CPAN/
(27) ftp://ftp.saintjoe.edu/pub/CPAN
(28) ftp://ftp.sunsite.utk.edu/pub/CPAN/
(29) ftp://ftp.uwsg.iu.edu/pub/perl/CPAN/
(30) ftp://linux.cs.lewisu.edu/pub/CPAN
(31) ftp://mirror.candidhosting.com/pub/CPAN
(32) ftp://mirror.cc.columbia.edu/pub/software/cpan/
29 more items, hit SPACE RETURN to show them
Select as many URLs as you like. Type individual indexes or hyphenated
ranged separated by spaces. E.g., '1 4-10 12 13-15 '.
(Empty input finishes this (URL) section. Type "show" to see your
picks.) []