Re: Use of Spllic command
Kevin Butters wrote: > > A real beginner here. > > I have an array with 5 elements, 0-4. I want to insert > values into the array at position 2. Do I use the > splice command? Yes. > splice(@array, 1, "value"); > print "@array\n"; > 0 1 2 3 4 5 $ perl -le'$,=$"; @array = (0 .. 4); print @array; splice @array, 2, 0, "value"; print @array; ' 0 1 2 3 4 0 1 value 2 3 4 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Use of Spllic command
On Tue, 12 Feb 2002 14:46:45 -0800 (PST), Kevin Butters <[EMAIL PROTECTED]> wrote: > I have an array with 5 elements, 0-4. I want to insert > values into the array at position 2. Do I use the > splice command? > > splice(@array, 1, "value"); > print "@array\n"; > 0 1 2 3 4 5 You forgot the length argument to the splice function #!/usr/bin/perl -w use strict; my @array = (0..4); print "@array\n"; splice(@array, 1, 1, "value"); print "@array\n"; __END__ -- briac << dynamic .sig on strike, we apologize for the inconvenience >> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Use of Spllic command
A real beginner here. I have an array with 5 elements, 0-4. I want to insert values into the array at position 2. Do I use the splice command? splice(@array, 1, "value"); print "@array\n"; 0 1 2 3 4 5 __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]