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 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: parsing sloppy text from columns
by rob_au (Abbot) on May 08, 2003 at 03:29 UTC | |
|
Re: parsing sloppy text from columns
by draconis (Scribe) on May 08, 2003 at 17:57 UTC | |
by Aristotle (Chancellor) on May 10, 2003 at 19:29 UTC | |
by draconis (Scribe) on May 12, 2003 at 13:27 UTC |