good chemistry is complicated,
and a little bit messy -LW
accessing the result of a match as an arrayby intuited (Novice)
|on Dec 24, 2009 at 21:48 UTC||Need Help??|
intuited has asked for the wisdom of the Perl Monks concerning the following question:
In my laziness, impatience, and hubris I have reached the conclusion that this question is worthy of your attention. If I am mistaken, please put the blame on one of the aforementioned personality traits.
I'd like to access the result of a pattern match as an array without assigning it to a variable first. Doing this the non-lazy way goes like this:
but this is clearly unacceptable.
I've tried a couple of different approaches, which give different errors:
The Book $(man perldata) mentions that the Great Creator of perl has given it 'three built-in data types: scalars, arrays of scalars, and associative arrays of scalars, known as "hashes"'. However I see now that there are some quantum particles whose existence proves such dogma to be somewhat oversimplified. The psalm $(perldoc -f scalar) does provide a solution to my practical concerns:
but also mentions that "There is no equivalent operator to force an expression to be interpolated in list context because in practice, this is never needed."
This revelation suggests that there may be a better way to do this, and also increases my hunger for understanding of the Great Mysteries of perl.
And so it is with
Thank you, o great esteemed Monks.