while (<>) { if (/^(\w+)\s+(\d+)(.*)/) { printf "%s %d %s\n", $1, (exists $disk{$1} ? 0 : ($2+$partition)), $3; } else { print } }