in reply to RegExp error PLEASE HELP!

Your error is the fact that you need to escape the characters for $PATTERN

splitAB($S, '\?'); splitAB($b, '\#');
But I also see you are using some reserved variables $a = $b = ''; your would be better off renaming those variables to something other than $a; $b; like my $data_a;