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

Re: [MacPerl] Commenting blocks of code



On Thu, Mar 09, 2000 at 08:14:49AM -0800, Brian McNett wrote:
> 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.

You have the meanings of the switches completely backwards.

The switches -p and -n provide a while (<>) loop around your program.  The
former also provides a continue block that prints the value of $_.

The switch -l sets $\ (the output record separator), and, when used with -p
or -n, adds a chomp() to the beginning of the while loop.
-l octnum sets $\ to chr(octnum).  -l sets $\ to the value of $/.


Please review the perlrun documentation.


Ronald

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