#!/usr/bin/perl -w my $filename = "quotas.txt"; open FILE, "$filename" or die "Cannot open $filename for reading: $!\n"; open REPORT, ">report.csv" or die "Cannot open report.csv for writing: $!\n"; undef $/; my $file = ; $/ = "\n"; my ($header,@records) = split /directory\s+/, $file; while (@records){ my $line = shift @records; if ($line !~ /\.\.\./) { my ($path, $usage, $threshold) = $line =~ / (\S+) #grab path \D+ (\d\S+) #stop at the first digit for usage .*? \[hard-threshold\] #seek out threshold .*? \(\s+(.*?)\) #capture threshold inside parens /sx; print REPORT "$path,$usage,$threshold\n"; } print $line # else { # my ($usage, $path, $threshold) = $line =~ / \S+ #grab path # \D+ # (\d\S+) #stop at the first digit for usage # .*? # (\S+) # \[hard-threshold\] #seek out threshold # .*? # \(\s+(.*?)\) #capture threshold inside parens # /sx; # print "$path,$usage,$threshold\n"; # } }