in reply to Re: Re: Re: DWIM on sub input
in thread DWIM on sub input
I want to keep 3 good elements. Split to 4 and keep the first 3.#!/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'
------
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.
|
|---|