in reply to Save Split to Array
Your problem seems to be understanding split. Any part of your string that matches the regular expression argument will be removed -- only the remaining parts populate the returned array.
my $string = "This word:ding, is:a sound."; $,='!'; #prints "This!word:ding,!is:a!sound." print split( /\s/, $string ); #prints "This word!ding, is!a sound." print split( /:/, $string ); #prints "Th! word:ding, !:a sound." print split( /is/, $string);
|
|---|