Help for this page

Select Code to Download


  1. or download this
    s/^\s+//g, s/\s+$//g for $value;
    
  2. or download this
    sub trim {
       local $_ = @_ ? $_[0] : $_;
    ...
    $trimmed = trim;                      # Trims $_ by default.
    @trimmed = map trim, @untrimmed;      # Trim a whole list. (readable)
    push(@trimmed, trim) for @untrimmed;  # Trim a whole list. (efficient)