$string = 'a=1;b=2';
use Data::Dumper;
@array = split("; ?", $string);
print Dumper(\@array);
output:
$VAR1 = [
'a=1',
'b=2'
];
Anyone knows how "; ?" work here?It’s not regex, but works quite like regex,so I don’t understand.
I think it means “semicolon followed by optional space (just one or zero)”.
The pattern parameter to split is always treated as a regular expression (would be better to not use a string, though). The only exception is the “single space”, which is taken to mean “split on whitespace”