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

Re: [MacPerl] Code cleaning and questions



On Thu, Jun 24, 1999 at 07:58:34PM +0000, Bart Lateur wrote:
> 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";

That doesn't print the ASCII values of the individual characters.  It seems
to me to be a Perlish and much faster way of doing something else.  :)

Ronald

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