[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Commenting blocks of code



Simply Hao <hao@netaxs.com> wrote:

> So you see, it's not obscure at all - just concisely idiomatic.

Uh, huh.  Thanks, Hao.  This, is more or less the way I'd put it:

This snippet relies on the fact that hash keys must be unique, uses 
unless() to test for uniqueness while building the hash, and only prints 
the (of necessity unique) keys as it's output. The "value" of each item 
in the hash, however is left undefined!

The reason I use:

#!perl -nl

Is that although enclosing the entire program in a while(<>) loop is 
valid syntactically, it's ugly, and Perl provides a switch "-l" to do 
this.  Two other switches, -n and -p both chomp newlines on input and 
append newlines on output, with -p having the additional property of 
printing each line as it's processed.  In this instance, I don't want the 
behavior provided by -p.  I need to suppress printing for lines which 
aren't unique.

Works must fine as a BBEdit filter.

--B

Brian McNett, Webmaster
*************************************************************
Mycoinfo. The world's first mycology e-journal.
http://www.mycoinfo.com/
*************************************************************


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org