I don't think that's a bad first-round (maybe phone-screen) question, provided the interviewer explains all parts of the syntax with which the candidate is unfamiliar.
provided the interviewer explains all parts of the syntax with which the candidate is unfamiliar.
If you're being asked this question, I'll bet that the company wants you to know the syntax of the language.
Bluntly put, if you 'know Perl' in the sense that you can write a VB program in your head and translate it to Perl, you don't know Perl.
To be a Perl programmer, you have to 'get' the syntax and the style. Regular expressions are your first choice for tasks, not an obscure library function.
A one-liner like this is a bit extreme, but it isn't out of reach for an actual Perl developer.
Oh, that's sick. Clever though--it tries the small factors first. It's not even all that obfuscated, if you're any good at regular expressions.
The way I figure it, questions like this are only fair if the candidate claims guru-level Perl knowledge.
I mean, if somebody claimed guru-level Lisp knowledge, they'd certainly get some questions about macros. And self-proclaimed Haskell hackers had better be able to explain monads. So asking a supposed Perl expert an easy regex question isn't unreasonable.
Yeah, I'm frustrated by resume puffery. Why do you ask? :-)