Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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 pondering the Monastery: (4)
As of 2014-09-21 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (167 votes), past polls