My friend's problem was trying to deal with the "empty" columns in the data lines. When just using a naive split(), the empty columns would disappear, throwing off the count.Filesystem blocks quota limit grace files ... /dev/hdd3 26320 46080 51200 1521 ... /dev/hdd4 26320 51200 1060 ...
# controlled search-and-replace to insert column markers # using the header line as a guide to where the columns lie $headers = <>; $headers =~ s/(\S)\s/$1\#/g; while (<>) { s/\s/ (substr($headers, pos(), 1) eq '#')? '#' : ' ' /eg; @_ = split /\s*\#\s*/; # @_ now has true columns ready for whitespace trimming }
In reply to parsing sloppy text from columns by halley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |