- or download this
my $str = "This is my program";
my @words = split ' ', $str;
- or download this
my @chunks = split /(\s+)/, $str;
- or download this
shift @chunks if $chunks[0] eq ''; # and then
my $s = $chunks[0] =~ /\s/ ? 1 : 0;
my $e = $chunks[-1] =~ /\s/ ? -2 : -1;
- or download this
my ($s,$e)=map $_ + ($chunks[$_] =~ /\s/ ?
($_ >=0 ? 1 : -1 ) : 0) => 0, -1;
- or download this
map {s/[^a-z ]//gi} @words;
- or download this
@words = map { (my $s=$_) =~ s/[^a-z ]//gi; $s } @words;
- or download this
y/\0//d for @chunks; # or @chunks[$e,$s];
- or download this
for ([split /(\s+)/, $str]) {
shift @$_ if $_->[0] eq '';
...
local $"='';
print "@$_";
}