Thread delete $array[$i] (8 answers)
Opened by rosti at 2018-12-10 19:05

rosti
 2018-12-11 11:04
#189370 #189370
User since
2011-03-19
2541 articles
BenutzerIn
[Homepage]
user image
Nun, wir haben ja tie():

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
use strict;
use warnings;
use Tie::Array;
use base qw(Tie::StdArray);

tie my @arr, 'main';
@arr = qw(foo bar baz);
delete $arr[0];

print Dumper \@arr;

sub DELETE{
    my $self = shift;
    my $idx  = shift;
    splice @$self, $idx, 1;
}


Und dann macht auch delete das was es soll ;)


.
http://rolfrost.de/framework
Postmodern MVC Framework für Perl5 mod_cgi, mod_fastcgi und mod_perl

View full thread delete $array[$i]