http://www.perlmonks.org?node_id=1226300

Xilman has asked for the wisdom of the Perl Monks concerning the following question:

ISTM that the following three lines ought to be a one-liner

@headings = grep /^\s*AUID/, @lines; @headings = split ' ', $headings[0]; shift @headings;

In the above, I know that precisely one element of @lines contains a string of the form "AUID \cIRA \cIDec \cILabel \cIV \cIB-V \cIComments" and I'm trying to get an array which contains ('RA', 'Dec', 'Label', 'V', 'B-V', 'Comments'). I've tried numerous variants on

@headings = shift split ' ', grep /^\s*AUID/, @lines;
including adding parentheses around the grep in an attempt to force list context, but get either grep's result as a scalar 1 or weird and wonderful syntax errors. Can anyone help please?

FWIW, I voted "I am an idiot" in the recent poll "My code is most likely broken because:"