Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: trim() magic

by Aristotle (Chancellor)
on Jan 13, 2006 at 03:48 UTC ( #522875=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub trim {
        return trim( $_ ) if not @_;
    ...
        for ( @_ ) { s/^\s+//, s/\s+$// }
        return wantarray ? @_ : $_[ 0 ] if defined wantarray;
    }
    
  2. or download this
    sub trim2 {
        return trim2( $_ ) if not @_;
    ...
            if defined wantarray;
        for ( @_ ) { s/^\s+//, s/\s+$// }
    }
    
  3. or download this
    #!/usr/bin/perl
    use strict;
    ...
        undef_passed_1 => sub { my @l = ( '  asdf  ', '  asdf  ' ); trim1(
    + @l ); },
        undef_passed_2 => sub { my @l = ( '  asdf  ', '  asdf  ' ); trim2(
    + @l ); },
    };
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://522875]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2015-07-29 02:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls