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 warnings FATAL => 'all'; use autodie; open(INPUT, '<', 'result_3.csv'); my $nombre=0; my @fichiers; while((my $ligne=<INPUT> )) { next if($ligne=~/^\d+\s+\d{2}:\d{2}:\d{2}\s*$/); next if($ligne=~/^\s+$/); next if($ligne=~/^default/); if($ligne=~/,fault,/) { $nombre++; push @fichiers, (split(/,/, $ligne))[0]; } } close(INPUT); open(OUTPUT, '>', 'resultat.txt'); print OUTPUT join("\n", @fichiers); close(OUTPUT);
Guest Henriich möchte die File result_3.csv in mehrere file.csv
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 feature qw(say); use autodie qw(:all); scalar <DATA>; my @header = split /\s*,\s*/, <DATA>; chomp $header[-1]; my @outputFHs; for (1..@header-1) { open $outputFHs[$_], ">", "file$_"; say {$outputFHs[$_]} "$header[$_]:"; } while (<DATA>) { chomp; next unless length; my @cols = split /\s*,\s*/; for my $colNo (1..@header-1) { say {$outputFHs[$colNo]} "$cols[0] : $cols[$colNo]"; } } __DATA__ 20150627 19:08:00 default, prim, second, copy_direct, forced_copy, always_allow, type_of_dump, full_memory, d100spupt, /dev/lg_du, /dev/sysdu, /var/adm, 1, 1, fault, disallow, doc10, 5, fault, 7, ad8, 9, wu, disallow, doc11, 5, fault, 5g7, 8, te, 10, disallow, doc12, 5, fault, 7, ca, 9hg, 10, disallow, doc13, 5, fault, 7, 8, 35hg, 10, disallow,