merlyn@iwarp.intel.com (Randal L. Schwartz) (03/29/91)
In article <3539@inews.intel.com>, dmccart@morticia (D. J. McCarthy ~) writes: | - Is it the version I'm running? It does look mighty old. Yes. | - How can I do what I want to do without getting a new version? (It's | not that I don't want to, or that I don't have permission on the 490; | it's just that uunet doesn't like me.) Replace it with | #!/usr/local/bin/perl | | sub bynumber { $b <=> $a; } sub bynumber { $b - $a; } ## this works for *integers* only | $thisdie = 1; | while ($thisdie <= 4) { | @rolls[$thisdie] = int(rand(6)) + 1; $rolls[$thisdie] = int(rand(6)) + 1; | } | | @sortrolls = sort bynumber @rolls; @foo[] gives you an array of variables, where $foo[] gives you a scalar variable. Personally, I'd code that more like: sub bynumber { $b - $a; } @rolls = (); for (1..4) { push(@rolls, int(rand(6)) + 1; } @rolls = sort bynumber @rolls; print "Just another Perl hacker," -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/