in reply to splitting punctuation in a text
use strict; use warnings; use Data::Dumper; my $str = 'earth, wind & fire'; $str =~ s/([,&])/ $1 /g; my @arr = split /\s+/, $str; print Dumper(\@arr); __END__ $VAR1 = [ 'earth', ',', 'wind', '&', 'fire' ];
I definitely think kyle's is simpler (and better), but sometimes it's worth seeing a different approach.
|
|---|