in reply to can split() use a regex?

To my mind, with the exception of the suggestion to use unpack and the one to use m///, both which should work, the rest of the above doesn't DWYM. If you want the number to be transferred to the first variable, split won't do that, because it excludes as delimiters whatever matches the regexp. Normally the bracketed part of the regexp would transfer matches to $1, $2 etc. NOT to the list returned by split by the way.

Unfortunately, in the case of running the regexp through split, this will cause match variables to be rendered undefined at the point where split returns.

There might be some nasty trick to force split to abort and leave match variables intact, but I can hardly recommend such an approach.

The OPs implied alternative for regexping without split when coded correctly, would look something like:

$line =~ /^(\d{4})(.*)$/ or die "unexpected content at line $.\n"; my ( $one, $two ) = ( $1, $2 );

-M

Free your mind