in reply to (Beginner) Can 'qw' be implemented into a list?
So qw is used (mostly) in list context to return a list, and yes you can assign a list to an array. Crucial concepts are: list and context. Basicly a list is an UNordered sequence of values. A list is like a primitive idea in Perl. Lists cannot be accessed using an index. Array are indexed lists so you can access one element by the mean of its index. Look for context at modernperl and obviously at perlmonks.qw/STRING/ Evaluates to a list of the words extracted out of STRING, using embedd +ed whitespace as the word delimiters. It can be understood as being r +oughly equivalent to: split(" ", q/STRING/); the differences being that it generates a real list at compile time, a +nd in scalar context it returns the last element in the list. So this + expression: qw(foo bar baz) is semantically equivalent to the list: "foo", "bar", "baz"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: (Beginner) Can 'qw' be implemented into a list?
by AnomalousMonk (Archbishop) on Mar 24, 2015 at 18:13 UTC | |
by Discipulus (Canon) on Mar 25, 2015 at 07:55 UTC | |
by AnomalousMonk (Archbishop) on Mar 25, 2015 at 15:24 UTC |