My enhancement of FirstTime.pm (used by CPAN.pm)

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.) []
 
A

Andrew

oops. discovered a couple of wording/typo errors in my post and code:
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 meant to say "hit SPACE RETURN" (that's the original text, and I
haven't changed it in my code)

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 '.

meant to say "hyphenated ranges". (Correction made on the pages I
referred to earlier)
 
A

Andrew

OK, this is the last time i am replying to myself in this thread (at
least for a few weeks).

I got word from the author of the module (Andreas König) and learned
that my efforts coincide with a busy time for him, as he is releasing
CPAN version 1.84 imminently. He indicated general approval of my
changes, but that, due to the crunch, he could not incorporate them
into this release, and that, moreover, it would be best to subject my
version to extensive testing prior to release.

It is with regards to the testing that I decided to post here one more
time and explicitly ask for help to test the script.

Thanks in advance.

FWIW: { i spotted a couple of other careless errors:
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

That should have been "3-6 9-15 17 20-43" (to be equivalent to the
sequence above /it/)
(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 '.

Since "12-15" accomplishes the same thing as "12 13-15", with fewer key
strokes, I changed the example in the prompt to "1 4-8 10 13-15"

}

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top