Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2017-12-12 22:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (340 votes). Check out past polls.

    Notices?