From geary at prismnet.com Mon Feb 13 09:18:24 2012 From: geary at prismnet.com (Mark Geary) Date: Mon, 13 Feb 2012 12:18:24 -0500 (EST) Subject: [Columbus-pm] perl question Message-ID: <201202131718.q1DHIOn0052788@eris.prismnet.com> So, I've got this function that returns a list and I want to sort the returned list: sub rv (@) { reverse @_; } sort rv @list; but perl thinks I want to use rv as the sort comparison function. If I say: sort reverse @list; then perl knows what I want to do. How do I make the first statement work without adding lots of parentheses? Mark Geary From schemelab at gmail.com Tue Feb 14 04:27:29 2012 From: schemelab at gmail.com (Terrence Brannon) Date: Tue, 14 Feb 2012 07:27:29 -0500 Subject: [Columbus-pm] perl question In-Reply-To: <201202131718.q1DHIOn0052788@eris.prismnet.com> References: <201202131718.q1DHIOn0052788@eris.prismnet.com> Message-ID: Hi Mark, I figured someone would've answered by now who still lives in Columbus, but I guess not. Your question about getting the first statement to work... I presume the 'first statement' is sort rv @list; And presumably you have some form of this statement that works with parentheses? My solution would be: sort { $a <=> $b } (rv @list); But your best option is the 'Seekers of Perl Wisdom' section on perlmonks.org ... or perhaps ask on stackoverflow.com Good luck and regards from South Florida, Terrence (on my way to freeze and do Python in NYC) On Mon, Feb 13, 2012 at 12:18 PM, Mark Geary wrote: > So, I've got this function that returns a list and I want to sort the > returned list: > > sub rv (@) { reverse @_; } > sort rv @list; > > but perl thinks I want to use rv as the sort comparison function. If I say: > > sort reverse @list; > > then perl knows what I want to do. How do I make the first statement > work without adding lots of parentheses? > > Mark Geary > _______________________________________________ > Columbus-pm mailing list > http://columbus.pm.org/ > Columbus-pm at pm.org > http://mail.pm.org/mailman/listinfo/columbus-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From geary at acm.org Wed Feb 15 07:06:27 2012 From: geary at acm.org (Mark Geary) Date: Wed, 15 Feb 2012 10:06:27 -0500 (EST) Subject: [Columbus-pm] perl question In-Reply-To: References: <201202131718.q1DHIOn0052788@eris.prismnet.com> Message-ID: On Tue, 14 Feb 2012, Terrence Brannon wrote: > Hi Mark, I figured someone would've answered by now who still lives in Columbus, but I guess not. > Your question about getting the first statement to work... I presume the 'first statement' is > sort rv @list; > > And presumably you have some form of this statement that works with parentheses? My solution would be: > sort { $a <=> $b } (rv @list); I could call it as: sort(rv(@list)); but that doesn't look as cool. > But your best option is the 'Seekers of Perl Wisdom' section on perlmonks.org ... or perhaps ask on stackoverflow.com I suppose I will. I thought I'd start locally. Mark -- Don't forget to stop and eat the roses.