in reply to Re: DWIM on sub input
in thread DWIM on sub input

A few explanations:

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Re: DWIM on sub input
by halley (Prior) on Jul 16, 2003 at 14:37 UTC

    Split to 3 elements, because you only want to keep 3. You would have caught (1, 2, 3, 4) from "1,2,3,4,5,6,7".

    D'oh! I was wrong. But "4,5,6,7" == 4 ;)

    --
    [ e d @ h a l l e y . c c ]

      #!/usr/bin/perl my $x = '1,2,3,4,5,6,7'; my @x = split (/,/, $x, 3); my @y = (split (/,/, $x, 4))[0 .. 2]; { local $"="', '"; print "'@x'\n"; print "'@y'\n"; } ---------- '1', '2', '3,4,5,6,7' '1', '2', '3'
      I want to keep 3 good elements. Split to 4 and keep the first 3.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.