I am trying to split a line with multiple spaces. I just want to separate where there are 2 or more white spaces. I tried several things and I continue to get the same result, which is that it breaks after each letter. Here is the last thing I tried
@cellMessage = split(s/ {2,}//g, $message); foreach(@cellMessage){ print "$_ \n"; }
@cellMessage = split(/ {2,}/, $message);
Keeping the syntax that you used in your example, I would recommend the following:
@cellMessage = split(/\s{2,}/, $message); foreach(@cellMessage){ print "$_ \n"; }
(, ..). , split , //, $message .
split
//
$message
use strict; use warnings; use Data::Dumper; # 1 22 333 my $message = 'this that other 555'; my @cellMessage = split /\s{2,}/, $message; print Dumper(\@cellMessage); __END__ $VAR1 = [ 'this that', 'other', '555' ];
:
@cellMessage = split (/\ s +/, $message);
, "@cellMessage = split (/{2,}/, $message); imo.
: \b(\s{2,})\b
\b(\s{2,})\b
- .