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

Re: [MacPerl] Commenting blocks of code



>#!perl -w
># This script comments Perl source.
>
>while(<>)
>{
>  print "# $_";
>}
>
>
>#!perl -w
># This script uncomments Perl source.
>
>while(<>)
>{
>  s/^# *//;
>  print $_;
>}


Hmm...

#!perl -wpl
# Uncomments and comments Perl source.
if (/^#/) {
    s/^# *//g;
    }
else
    {
    s/(^.*)/# $1/g;
}

NOT robust, or fully tested.  May prove harmful to small animals. 
Uncomments "real" comments (dangerous side-effect), so use only on fully 
commented/uncommeneted snippets of CODE. Further refinement is left as an 
exercise for the reader. ;-)

Your text editor can handle this better.

--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