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

Re: [FWP] Goal oriented programming



Quoting Vicki Brown (vlb@cfcl.com):
> One of the other list members suggested this more Perlish replacement
> 
>     foreach (split //, $line) {
>       $num = ord $_;
>       $num > 127 and warn "ASCII value exceeds 127.\n";
>     }

I can't help thinking that the truly Perlish way to do it would be

$hicount=$line =~ tr/\x80-\xFF//;
warn "ASCII value exceeds 127.\n" x $hicount
  if ($hicount);

It would be better without the temporary variable, but I can't think of a
straightforward way to get rid of it right now.

-- 
Adam Rice -- wysiwyg@glympton.airtime.co.uk -- Blackburn, Lancashire, England

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org