Skip Menu |

This queue is for tickets about the Acme-BooK-Is-My-Bitch CPAN distribution.

Report information
The Basics
Id: 21298
Status: resolved
Priority: 0/
Queue: Acme-BooK-Is-My-Bitch

People
Owner: Nobody in particular
Requestors: book [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.01
Fixed in: 0.03



Subject: %methods doesn't need to list the number of %s...
Since %methods contains the string that is passed to sprintf(), you do not need to pass the number of items needed. You only have to count the number of %s in the string. And I think you can use the goaste operator for that... ;-)
From: BOOK [...] cpan.org
On Sun Sep 03 11:00:56 2006, BOOK wrote: Show quoted text
> Since %methods contains the string that is passed to sprintf(), you > do not need to pass the number of items needed. You only have to count > the number of %s in the string. > > And I think you can use the goaste operator for that... ;-)
Here's the patch.
From: BOOK [...] cpan.org
On Wed Sep 06 08:09:58 2006, BOOK wrote: Show quoted text
> On Sun Sep 03 11:00:56 2006, BOOK wrote:
> > Since %methods contains the string that is passed to sprintf(), you > > do not need to pass the number of items needed. You only have to count > > the number of %s in the string. > > > > And I think you can use the goaste operator for that... ;-)
> > Here's the patch.
Sorry, it didn't seem to be attached.
--- Acme-BooK-Is-My-Bitch-0.02/lib/Acme/BooK/Is/My/Bitch.pm 2006-09-03 12:44:05.000000000 +0200 +++ Acme-BooK-Is-My-Bitch-patch/lib/Acme/BooK/Is/My/Bitch.pm 2006-09-06 14:06:34.000000000 +0200 @@ -21,38 +21,39 @@ my %methods = ( 'tell_the_truth' => [ 'You know, my favorite pornstar is definitely %s.', - 'pornstars', 1 + 'pornstars', ], 'thats_nothing' => [ 'Oh, that\'s nothing! You should\'ve seen what I auctioned in %s!', - 'yapc', 1 + 'yapc', ], 'code' => [ 'You know, I wrote some code for the %s space mission, but it was rejec ted for its lack of clarity...', - 'space_missions', 1 + 'space_missions', ], 'next_talk' => [ 'My next lightning talk will be called "%s! %s!! %s!!!"', - 'batman', 3 + 'batman', ], 'next_yapc' => [ 'I think the next YAPC should be on %s!', - 'planets', 1 ], + 'planets', ], 'sql' => [ 'I think we can solve that with a %s %s %s', - 'sql', 3 ], + 'sql', ], 'twisted_perl' => [ 'I\'m pretty sure I could do that just by using %s and %s', - 'opcodes', 2 + 'opcodes', ], 'words_of_wisdom' => [ 'My grandfather once told me: ' . join( " ", ('%s') x 7 ), - 'loremipsum', 7 + 'loremipsum', ], ); for my $method ( keys %methods ) { - my ( $template, $theme, $qty ) = @{ $methods{$method} }; + my ( $template, $theme ) = @{ $methods{$method} }; + my $qty =()= $template =~ /%s/g; no strict 'refs'; *{$method} = sub { return sprintf( $template, metaname( $theme => $qty ) ) };