Help for this page

Select Code to Download


  1. or download this
    my $string = EXPR; $string =~ s/^\s+|\s$//g;
    
  2. or download this
    (my $string = EXPR) =~ s/^\s+|\s$//g;
    
  3. or download this
    sub trim { my ($s) = @_; $s =~ s/^\s+|\s$//g; return $s; }
    my $string = trim( EXPR );
    
  4. or download this
    s/^\s+|\s$//g for my $string = EXPR;
    
  5. or download this
    my ($string) = map { my $s = $_; $s =~ s/^\s+|\s$//g; $s } EXPR;
    
  6. or download this
    use List::MoreUtils qw( apply );
    my $string = apply { s/^\s+|\s$//g } EXPR;
    
  7. or download this
    use Algorithm::Loops qw( Filter );
    my $string = Filter { s/^\s+|\s$//g } EXPR;