Skip Menu |
 

This queue is for tickets about the Text-Autoformat CPAN distribution.

Report information
The Basics
Id: 85158
Status: resolved
Priority: 0/
Queue: Text-Autoformat

People
Owner: DCONWAY [...] cpan.org
Requestors: ZUMMO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: our %ignore
Please declare %ignore with "our" instead of "my", so I can mess with it ;)
Subject: Re: [rt.cpan.org #85158] our %ignore
Date: Mon, 13 May 2013 18:54:34 +1000
To: bug-Text-Autoformat [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Download (untitled) / with headers
text/plain 1.1k
Show quoted text
> Please declare %ignore with "our" instead of "my", so I can mess with it ;)
Sorry, Alessandro, but I can't do that. Interfaces that include package variables are nasty and dangerous. So, instead, I'll give you something much safer, and yet even more powerful. ;-) I just uploaded a new version of the module that allows you to pass a subroutine reference to the 'case' option. That subroutine is applied to each word and whatever it returns is how the word is transformed. For example: my $text = "so i can mess about with it in evil ways"; sub my_casing { my @LOWER = qw( about can ); my @UPPER = qw( evil mess ); my ($word) = @_; return $word ~~ @LOWER ? lc($word) : $word ~~ @UPPER ? uc($word) : ucfirst(lc($word)); } print autoformat {case => 'title'}, $text; # So I Can Mess About With It In Evil Ways print autoformat {case => 'highlight'}, $text; # So I Can Mess About with It in Evil Ways print autoformat {case => \&my_casing}, $text; # So I can MESS about With It In EVIL Ways Hope that helps! Damian
Closing as resolved, given Damian's change.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.