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

Re: [FWP] Problem - rewrite and simplify



At 14:37 -0400 6/30/99, John Porter wrote:
>> 	  while ($line = <CLONEIDSLIST>) {
>> 	     chop($line);
>> 	     push(@ids, split(/, /, $line));
>
> First, your code would be improved by:
>   a) using chomp() instead of chop();
>   b) used defined() in the while test.

Yeah. I pulled this from a project I was doing at Previous Company Unnamed.
They were stuck in the stone age of Perl 4.

My apologies for not updating the example before posting... I'm going
through my collection and posting it gradually into the stream.

> Which of course leads to:
>
>   @ids = map { chomp; split /, / } <CLONEIDSLIST>;

nicely done.  (And nicely shown how you got there! (our learning Perl
faction will thank you).
-- --
       |\      _,,,---,,_       Vicki Brown <vlb@cfcl.com>
 ZZZzz /,`.-'`'    -.  ;-;;,_   Journeyman Sourceror: Scripts & Philtres
      |,4-  ) )-,_. ,\ (  `'-'  P.O. Box 1269  San Bruno  CA  94066
     '---''(_/--'  `-'\_) http://www.cfcl.com/~vlb  http://www.macperl.com

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