|< 1 2 >| | 16 Einträge, 2 Seiten |
Quotekabel@kabelskiste:~$ perl
%hash1 = (1 .. 8 );
%hash2 = (4 .. 11);
@hash2{keys %hash1} = values %hash1;
foreach (keys %hash2) {
print $_, $hash2{$_}, $/;
}
89
67
12
45
34
78
1011
56
kabel@kabelskiste:~$
1
2
3
4
5
6
7
my %hash1 = (key1 => 'value1',
key2 => 'value2');
my %hash1 = (key3 => 'value3',
key4 => 'value4');
my %hash_gesamt = (%hash1,%hash2);
#oder
%hash1 = (%hash1,%hash2);
1
2
3
4
5
6
my @array = (1..4);
my @array2 = (5..11);
#entweder
my @array3 = (@array,@array2);
#oder
push(@array,@array2);
my $size = (@a1>@a2?@a2:@a1);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @array = ({key1 => 'value1',
key2 => 'value2'});
my @array2 = ({key3 => 'value3',
key4 => 'value4'},
{key5 => 'value5'});
my @new_array = @{join_arrays(\@array,\@array2)};
print Dumper(\@new_array);
sub join_arrays{
my ($ar1ref,$ar2ref) = @_;
my @array = ();
if(scalar(@{$ar2ref}) > scalar(@{$ar1ref})){
my $tempref = $ar2ref;
$ar2ref = $ar1ref;
$ar1ref = $tempref;
}
for(0..(scalar(@{$ar1ref}) - 1)){
$array[$_] = ${$ar1ref}[$_];
%{$array[$_]} = (%{$array[$_]},%{${$ar2ref}[$_]}) if(${$ar2ref}[$_]);
}
return \@array;
}
|< 1 2 >| | 16 Einträge, 2 Seiten |