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
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?@headings = shift split ' ', grep /^\s*AUID/, @lines;
FWIW, I voted "I am an idiot" in the recent poll "My code is most likely broken because:"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: shift split grep question (updated)
by haukex (Archbishop) on Nov 25, 2018 at 19:23 UTC | |
by Eily (Monsignor) on Nov 25, 2018 at 19:44 UTC | |
by haukex (Archbishop) on Nov 25, 2018 at 20:04 UTC | |
by BillKSmith (Monsignor) on Nov 25, 2018 at 21:59 UTC | |
|
Re: shift split grep question
by tybalt89 (Monsignor) on Nov 25, 2018 at 18:52 UTC | |
|
Re: shift split grep question
by eyepopslikeamosquito (Archbishop) on Nov 25, 2018 at 20:34 UTC | |
|
Re: shift split grep question
by LanX (Saint) on Nov 25, 2018 at 18:58 UTC | |
by haukex (Archbishop) on Nov 25, 2018 at 19:25 UTC | |
|
Re: shift split grep question
by Xilman (Hermit) on Nov 25, 2018 at 20:29 UTC |