Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

New sections and move one

by aquacade (Scribe)
on Aug 12, 2001 at 07:30 UTC ( [id://104207]=monkdiscuss: print w/replies, xml ) Need Help??

Please move Perl News from top to leftovers.

Please consider adding three new sections "New2Perl", "Perl 6", and "Subroutine Library" to the top.

I think these new sections would better classify some continuously recurring questions.

The "Subroutine Library" section is not like the snippets or Code Catacombs (but perhaps belongs under the catacombs). It would be classified, ready to use 'cut & paste'-able subroutines anyone can call for frequently asked how-to-do-its! The Monks could even bake-off subroutines and the first, best submission left standing as the Monks best efforts (based on XP?) gets promoted into the Perl Monks Subroutine Library.

I think there are a lot of wasted-cycles by higher level Monks reanswering the same questions over and over and over. I've searched this site for solutions, but until I discovered SuperSearch my searches were empty or returned too many hits. Using SuperSearch I still chase lots of links, I'm mostly looking for code that already works. It's hard to arbitrate one suggestion over another and usually they are snippets that I cannot always understand how to incorporate. I realize we cannot make a subroutine for every situation, but having some library of reusable code would help newer users.

BTW I'd like to see someone spend time reorganizing the sublinks in Code Catacombs in ASCIIbetical order. A few sublinks are sorted, most links sublinks are not.

Thanks for your time and consideration!

..:::::: aquacade ::::::..

Replies are listed 'Best First'.
Re (tilly) 1: New sections and move one
by tilly (Archbishop) on Aug 12, 2001 at 09:01 UTC
    If you are looking for general-purpose subroutines that are ready to run, the right place to look is CPAN, not PerlMonks.
      Err... Then what are the Monastery's Snippets, Code Catacombs, Craft, and Cool Uses For Perl sections for?
        Snippets are for useful idioms and tricks. I use Code Catacombs for code that I found fun and interesting but which I am unwilling to package and support. Code Catacombs also works for applications and PerlMonks specific stuff. Cool Uses For Perl seems to be for small little applications that people found cool.

        The only one which I think would overlap CPAN much is Code Catacombs. And given a choice, I would prefer that people use CPAN...

      I'm using ActiveState for (yuk!) Windows cause that's my client platform. I have not been able to successfully install a CPAN module (as yet) unless ActiveState had it in it's PPM repository already. (I heard Brian Ingerson is on a leave of absence from ActiveState, when I called to complain that installing from the respository is throwing errors like never before, like missing dependent modules).

      Please excuse me quickly throwing together some examples of what I mean. They were quickly tested, but I'm sure someone could make them better! What I'm suggesting is like the following examples. Someone new to Perl could use these right away on faith and learn what they mean after they "Saved the Day!" with their boss or client.

      Update: Revised rtrim to use sexeger as suggested below!
      sub rtrim { # Right trim spaces my @out=@_; for (@out) { $_ = reverse $_; s/^\s+//; $_ = reverse $_; } return wantarray ? @out : $out[0]; } sub ltrim { # Left trim spaces my @out=@_; for (@out) { s/^\s+//; } return wantarray ? @out : $out[0]; } sub trim { # Trim extra spaces from both left and right my @out=@_; for (@out) { s/^\s+//; s/\s+$//; } return wantarray ? @out : $out[0]; } sub trimall { # Trim all extra spaces from both left and right and middle my @out=@_; for (@out) { $_= join ' ',split; } return wantarray ? @out : $out[0]; }
      Again, this could be the start of the "String related" category of the Perl Monks' "Subroutine Library." I don't think these kind of onezie subroutines would find a welcome home in CPAN as one routine per submission. If they were in a module, then I have the same 'discovery' and 'install' problems I have today. As onezies they would fail CPANTS for sure not being modules!

      ..:::::: aquacade ::::::..

        I remain unconvinced. For pure Perl modules on CPAN I have had good luck under Windows just downloading, untarring, and then copying them manually. Other than the need to find something that will handle .tar.gz files on Windows, I don't see what is gained by having such modules on PerlMonks.

        As for the examples that you give, your routines make perfect sense if you are working in a language like VB with poor string handling capability. But in Perl I, and I think most experienced Perl developers, find it much easier and more reasonable to just inline the regular expressions in question where needed.

        A better example might be something like:

        # Runs a system command with basic error handling. sub run_system { if ($verbose) { my ($cmd, @args) = @_; print "Running '$cmd'\n"; if (@args) { print " with arguments '@args'\n"; } } if (system(@_)) { my $cmd = shift; my $arg_msg = ""; if (@_) { $arg_msg = " with args ['@_']"; } confess("Running '$cmd'$arg_msg failed on return code ($?)\n"); } }
        But how many truly useful ones are there? The fact is that the built-ins in Perl combined with its flexibility make a lot of the basic utility functions you might write in a different language (VB, C, etc) pretty much useless. I cannot think of enough for me to want a new section. Instead I think that they belong in Snippets. True, that needs improvement (eg making it searchable). Perhaps it should have categories, etc. But I think that it is the right place for this.
        On a slightly off note,
        I think your rtrim example could be improved using sexegers.

        elusion :

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-19 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found