|< 1 2 >| | 12 Einträge, 2 Seiten |
push(@{$hash{users}},'user4');
splice(@{hash{users}},2,1);
print ${$hash{users}}[2],"\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %hash = (
'users' => ['user1', 'user2', 'user3']
);
my $users = $hash{'users'};
print Dumper $users;
print "Index highest user: ", $#{$users}, "\n";
for (0..$#{$users}) {
print "Index searched user: ", $_, "\n" if $users->[$_] eq 'user2';
}
@{ $hash{users}} = grep { ! /^users2$/ } @{ $hash{users} };
@{hash{users}} = grep {$_ ne 'user2'} @{hash{users}};
splice(@{$hash{users}}, map {++$i && $_ eq 'user2' ? ($i-1) : ()} @{$hash{users}},1)
1
2
3
4
...
for (0..$#{$users}) {
print "Index searched user: ", $_, "\n" if $users->[$_] eq 'user2';
}
|< 1 2 >| | 12 Einträge, 2 Seiten |