in reply to How to find empty in empty
The following script checks for an empty line with the
mighty regexp /^[\s]+$/ instead of
comparing with "".
#!/usr/local/bin/perl -w use strict; my (@names, @versions,$l,$e); $l=0; $e=0; while (<DATA>) { chomp; if (! /^[\s]+$/) { ($names[$l],$versions[$l])=split(/[\s]+/); $l++; } else { $e++; } } $,=", "; print "@names @versions\n"; print "empty lines=$e\n"; __DATA__ jan 2.76 feb 3.20 mar 1.6 apr 4.00
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: How to find empty in empty
by petral (Curate) on Nov 19, 2002 at 15:44 UTC |