Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Comment on

...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

In reply to Re^3: Multiple foreach loops in single statement by Athanasius
in thread Multiple foreach loops in single statement by gurpreetsingh13

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (9)
    As of 2014-12-27 08:30 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (176 votes), past polls