#!/usr/bin/perl use feature 'say'; use strict; use warnings; my $str = " a \n \n b\n"; say $str =~ s/^\s*|\s*$//mgr; $_ = " a \n\n b\n"; s/^\s*|\s*$//gm; print "$_\n";
Standard input is empty
a b ab
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!