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

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 ]

Replies are listed 'Best First'.
Re4: DWIM on sub input
by dragonchild (Archbishop) on Jul 16, 2003 at 14:46 UTC
    #!/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.