Kirk Wythers wrote:
> 
> On Dec 24, 2006, at 2:59 AM, John W. Krahn wrote:
> 
>> Yes I saw where you tested $year but since I don't have the actual 
>> data to
>> test with I had to guess, and I guess I guessed wrong.  :-)
> 
> I thought you did an amazing job at guessing what I intended without 
> being able to look at a datafile. The amount of "stuff" you were able 
> to shorten (or do without) was striking.
> 
>>>     #Stop reading data at the end of the file, when $year is  empty. 
>>> This
>>>     #gets you out of the datafile before the program chokes on  the 
>>> footer.
>>>     exit unless $year;
>>
>> Instead of exiting from the program you should change the eof test 
>> above to:
>>
>>     if ( eof || !/\S/ ) {
>>         close ARGV;
>>         next;
>>         }
> 
> Fantastic... It works!
> 
> So the above change says close and reset if end of file or some  regular
> expression that finds a blank line (is the translation of !/ \S/ not
> string?

\s is the whitespace character class which is short for [ \t\f\r\n] and \S is
the non-whitespace character class which matches anything that is not a
whitespace character so !/\S/ is true if the current line does not contain any
non-whitespace characters.



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to