in reply to Re^2: Multiple foreach loops in single statement
in thread Multiple foreach loops in single statement
...we can provide a list too in split function.
Sorry, no. split operates on a single string (a scalar), but not on a list:
13:57 >perl -wE " $s = q[abc]; $t = q[mno]; say for split(//, $s, $t); + " Argument "mno" isn't numeric in split at -e line 1. a b c 14:06 >perl -wE " $s = q[abc]; $t = q[mno]; say for split(//, ($s, $t) +); " Useless use of a variable in void context at -e line 1. m n o 14:06 >perl -wE " @u = (q[abc], q[mno]); say for split(//, @u); " 2 14:06 >
The docs however mention EXPR ... which I assumed to be a scalar.
Yes, your original assumption was correct. But split returns a list, which is why the output of split can be the subject of a foreach or a map.
Hope that helps,
Athanasius <°(((>< contra mundum
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Multiple foreach loops in single statement
by gurpreetsingh13 (Scribe) on Oct 24, 2012 at 14:51 UTC | |
Re^4: Multiple foreach loops in single statement
by gurpreetsingh13 (Scribe) on Oct 24, 2012 at 13:22 UTC | |
by Anonymous Monk on Oct 24, 2012 at 13:30 UTC | |
by Athanasius (Archbishop) on Oct 24, 2012 at 13:56 UTC | |
by ikegami (Patriarch) on Mar 02, 2013 at 22:54 UTC |
In Section
Seekers of Perl Wisdom