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

[MacPerl] Idioms



At the risk of annoying Matthias, I'd like to ask you folks for some
(Mac)Perl expressions that you consider idiomatic (i.e., terse and/or
not obvious by inspection).

*Please* send the submissions to mp-book@ptf.com, rather than to the list
as a whole; I'll summarize and/or include the idioms in the idiom chapter
of the MacPerl book.

Yours, Rich

P.S.    MacPerl idioms are *particularly* solicited!

P.P.S.  Here are some possibilities we've thought of, for starters:

  Bareword strings

	$a = Ptooey;

  Evaluating arrays in scalar context, to get the number of elements

	$argc = @ARGV;

  Function return values, used as constants

	tie(..., O_RDONLY, 0);	# O_RDONLY() is a function

  Grab a copy of something and operate on it

	($copy = $something) =~ ...

  Implicit use of $_

        chomp;
	while (<>) { ...
	if (/^foo/) { ...

  Logical operators, used for flow control

	open(...) || die();
	open(...) or die();

  Scalar values, used as booleans

	if ($foo) { ...


Rich Morin, Canta Forda Computer Laboratory | Prime Time Freeware - quality
  UNIX consulting, training, and writing    | freeware at affordable prices
  P.O. Box 1488, Pacifica, CA, 94044, USA   | www.ptf.com      info@ptf.com
  rdm@cfcl.com            +1 650-873-7841   | +1 408-433-9662   -0727 (Fax)



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch