in reply to Split confusion
Welcome back!
Output:use strict; use warnings; use Data::Dumper (); my $name = "SMITH-JONES"; my @temp = split(/(-| )/,$name); print Data::Dumper::Dumper(\@temp); $name = "SMITH JONES"; @temp = split(/(-| )/,$name); print Data::Dumper::Dumper(\@temp);
Seems to work, are you sure you have an actual space on the RHS of the |?$VAR1 = [ 'SMITH', '-', 'JONES' ]; $VAR1 = [ 'SMITH', ' ', 'JONES' ];
Also, seems like you could be kind to your computer and not save the capture results:
Final suggestion is to use the exact same regex in the if as you do in the split.my @temp = split(/(?:-| )/,$name);
|
---|