Re: Spaceship Operator - I canna git it t' worrrk, cap'n!

by "Shaun L. Sides" <arch(at)abts.net>

 Date:  Sun, 9 Apr 2000 04:59:58 -0400
 To:  hwg-languages(at)hwg.org
 In-Reply-To:  yahoo
  todo: View Thread, Original
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6 Apr 2000, at 13:40, Quackamoe T-Bird-S wrote:

> #!/apps/LWperl/bin/perl -w[1]
> while (<>){     # reads the file of numbers
> @wordlist = $_;
> @sortwordlist = sort { $a <=> $b } @wordlist;
> print @sortwordlist; 
> }

In line 3, you're overwriting the array with each pass through the 
while loop.  use push to add the next element to the array with 
each pass, and chomping it would be a good idea, too.  Then you 
want to have the sort routine outside the while loop (after it).

Hope that helps. ;-)

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.2 -- QDPGP 2.61a
Comment: http://community.wow.net/grt/qdpgp.html

iQCVAwUBOPBGjSEw9uEAOtM/AQLj+gP/cGUnqso5UNe4KwQ6xUkLJJZL+qJWiO84
WcdHgIixA5cnTBgoM67VbIP9W6hpOZ1QSVw9aoEe6rJTNv7cx3oIpTruEqU/oux8
hxF/4gUz85F83SH9LNOrL5MU4ouBpnElkoKX8dwX52SJ6yV6Dlt4GrWcdQAr2o1O
S8w6NAjWwgM=
=trno
-----END PGP SIGNATURE-----

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.