Andrew Gaffney wrote:
Wiggins d'Anconia wrote:

Andrew Gaffney wrote:

I have an array that I need to remove an element from the middle of. Is there a one-liner way to do this?


perldoc -f delete perldoc -f splice

Helps?


A little, but I don't know how to put it all together.

I tried to write a small test script to figure this out, but I can't get anywhere. I used array references in my test program, because I need to pull out an element from an array through a ref and assign the result back to the same array ref. Here's what I've got:


#!/usr/bin/perl

use strict;
use warnings;

my $array1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

my $array2 = [EMAIL PROTECTED] @{$array1}, 0, 6};
my $array3 = [EMAIL PROTECTED] @{$array1}, 7};
push @{$array2}, @{$array3};
print join ', ', @{$array1} . "\n";

This gives me the following when I run it:

Can't use string ("5") as an ARRAY ref while "strict refs" in use at ./array.pl line 8.

What am I doing wrong?

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to