I dislike using regexes when simple string functions can handle the job.
By extracting the magic delimiter characters into a predefined constant, the code is clearer and more easily extendable. split will partition an input string on any of those special characters, and the wrapper (xx)[0] extracts the first element from the resulting list.
my @DELIMS = (qw( _ @ )); for my $elem ( @inputs ) { push @result, ( split /[@DELIM]/, $elem )[0]; }
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
In reply to Re: Regex issues
by TomDLux
in thread Regex issues
by mrras25
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |