Thread Liste in Tabellenformat umwandeln (19 answers)
Opened by Rambo at 2016-06-24 15:19

Gast janus
 2016-06-24 16:52
#184960 #184960
Wenn SamAccountName eindeutig ist:

Code (perl): (dl )
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
31
32
use strict;
use warnings;
use Data::Dumper;

my $result = {};
my $oid    = '';
while(my $lin = <DATA> ){
    chomp $lin;
    my ($att, $val) = split /\s+?:\s+?/, $lin
        or next;
    
    if( $att eq 'SamAccountName'){
        $result->{$val} = {};
        $oid = $val;
    }
    $result->{$oid}{$att} = $val;
}
print Dumper $result;


__DATA__
SamAccountName  : U011004
LastLogonDate   : 20.06.2016 15:01:10
ExpiryDate      : 19.12.2016 13:58:05
PasswordLastSet : 20.06.2016 14:58:05
mail            : J.W@dbx.com

SamAccountName  : U011001
LastLogonDate   : 25.05.2016 09:53:51
ExpiryDate      : 23.11.2016 08:53:28
PasswordLastSet : 25.05.2016 09:53:28
mail            : MM.AA@yxz.de


$result sieht so aus:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$VAR1 = {
          'U011004' => {
                         'SamAccountName' => 'U011004',
                         'PasswordLastSet' => '20.06.2016 14:58:05',
                         'ExpiryDate' => '19.12.2016 13:58:05',
                         'mail' => 'J.W@dbx.com',
                         'LastLogonDate' => '20.06.2016 15:01:10'
                       },
          'U011001' => {
                         'SamAccountName' => 'U011001',
                         'PasswordLastSet' => '25.05.2016 09:53:28',
                         'ExpiryDate' => '23.11.2016 08:53:28',
                         'mail' => 'MM.AA@yxz.de',
                         'LastLogonDate' => '25.05.2016 09:53:51'
                       }
        };


und das kannst Du beliebig verarbeiten.
Last edited: 2016-06-24 17:21:13 +0200 (CEST)

View full thread Liste in Tabellenformat umwandeln