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

Re (tilly) 1: New sections and move one

by tilly (Archbishop)
on Aug 12, 2001 at 09:01 UTC ( [id://104212]=note: print w/replies, xml ) Need Help??


in reply to New sections and move one

If you are looking for general-purpose subroutines that are ready to run, the right place to look is CPAN, not PerlMonks.

Replies are listed 'Best First'.
Re: Re (tilly) 1: New sections and move one
by chipmunk (Parson) on Aug 12, 2001 at 19:23 UTC
    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...

Re: Re (tilly) 1: New sections and move one
by aquacade (Scribe) on Aug 12, 2001 at 19:48 UTC
    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.
        I agree with you completely, from your point of view! The very new users I'm thinking of are coming from VB, Java, C, or whatever, could use a "crutch" to get their job done UNTIL they themselves are as you put it "experienced Perl programmers."

        Please step "outside the box" for just a moment where as a new Perl user I'm trying to build a mental bridge from any other programming language to Perl while resynthesizing this knowledge into working code to, in my example stay gainfully employed.

        The subroutines would not only point someone toward WHAT they need to lookup in the Camel and learn, but eliminate the thrashing around with 'how in the heck can I do THAT in Perl.'

        You are greatly respected. Enough that you were a valued reviewer of the new 3rd Llama. I defer to you and other elder wise Monks regarding the value of a "Subroutine Library" section. What I showed is not meant to be a module, but four separate routines showing HOW it could be done in Perl.

        Other personal examples I've needed are: to commatize an integer or float, to round to whole dollars (not trunc), to right or left pad string or number, and so on. Yes I can, with much effort, research, and embarassment, eventually find an answer. I envision the "Subroutine Library" as a companion link to the "New2Perl" link for new Perl users not experts.

        As a contrite Monk, I can only petition for change. I love this site and and thankful for the help I'm receiving. Thanks again for sharing your perspectives!

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

      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: note [id://104212]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-03-29 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found