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

Re: [MacPerl] Code cleaning and questions

On Thu, 24 Jun 1999 12:20:34 -0400, Ronald J Kimball wrote:

>Tip #2.  Try to program in Perl, not in C.  The for loop above is how you
>would solve this problem in C.  A more Perlish way would be:
>foreach (split //, $line) {
>  print $num = ord $_;
>  $num > 127 and warn "WARNING -- ASCII value exceeds 127.\n";

Actually, no: a "Perlish" (and much faster) way to do something like
this would be:

  my $count = $line =~tr/\200-\377//;
  $count and 
    warn "WARNING -- $count ASCII value(s) exceed(s) 127.\n";

where "\200" is octal for character # 128 (one of those things you get
used to) and "\377" for character # 255. tr/...// doesn't change
anything, it jjust counts the occurences.

On Thu, 24 Jun 1999 13:15:01 -0500, Robert Pollard wrote:

>I have looked for "$_" throughout the documentation in both the MacPerl: Power
>and Ease and in the documentation.  I can't find it anywhere.  I wish I could
>do a keyword search but I can't and it takes time to find these things.

Check "perlvar", "var" standing for "special VARiables". Yes, it takes a
bit of time getting used to where to find what documentation. On top of
your list should be:

	perlfunc   the basis (FUNCtions)
	perlop     what isn't in perlfunc (OPerators)
	perlre     Regular Expressions
	perlvar    special VARiables

and, last but not least:

	perlfaq    Frequently Asked Questions, an overview of the most
common "how do I" questions. Answers are in 9 other documents: 
perlfaq1 -> perlfaq9.


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