Thread Datei nach String durchsuchen und in Datei ausgeben (42 answers)
Opened by QWERTZ7 at 2011-03-22 10:49

rosti
 2011-03-25 23:12
#146927 #146927
User since
2011-03-19
3492 Artikel
BenutzerIn
[Homepage]
user image
Code: (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
use strict;
use Data::Dump qw(dump);
use Carp;

my $res = {}; # Results

my $i = 1;
while(my $line = <DATA>){
$line =~ /\((.*)\)/;
my @in = split /\s+/, $1;
my $s = qq($i => {$in[1] => "$in[2]", $in[5] => "$in[6]"});
#print "$s\n";
my $ref = eval($s) or croak "$@\n";
$res->{$i} = $ref;
$i++;
}

print dump $res;

__END__
Wed Mar 23 13:00:28 2011 : Auth: Login OK: [00-11-0A-FA-FB-AA/NOPASSWORD] (from client kgn751 port 31045 cli 00-11-0A-FA-FB-AA)
Wed Mar 23 13:01:02 2011 : Auth: Login OK: [00-0B-5D-0B-D6-44/NOPASSWORD] (from client WabeN7-55 port 11031 cli 00-0B-5D-0B-D6-44)
Wed Mar 23 13:01:22 2011 : Auth: Login OK: [00-00-85-7B-44-F7/NOPASSWORD] (from client e1-110-west port 36 cli 00-00-85-7B-44-F7)
Wed Mar 23 13:01:37 2011 : Auth: Login OK: [00-C4-FF-7F-34-07/NOPASSWORD] (from client e1-111-west port 76 cli 00-C4-FF-7F-34-07)
Wed Mar 23 13:05:29 2011 : Auth: Login OK: [08-37-FF-0C-E7-39/NOPASSWORD] (from client e1-140-west port 3 cli 08-37-FF-0C-E7-39)



Data::Dump
Code: (dl )
1
2
3
4
5
6
7
{
1 => { cli => "00-11-0A-FA-FB-AA", client => "kgn751" },
2 => { cli => "00-0B-5D-0B-D6-44", client => "WabeN7-55" },
3 => { cli => "00-00-85-7B-44-F7", client => "e1-110-west" },
4 => { cli => "00-C4-FF-7F-34-07", client => "e1-111-west" },
5 => { cli => "08-37-FF-0C-E7-39", client => "e1-140-west" },
}

View full thread Datei nach String durchsuchen und in Datei ausgeben