Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: trim() magic

by Aristotle (Chancellor)
on Jan 13, 2006 at 03:48 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://522875]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-19 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found