I am translating my Japanese Perl site to English.
I improve the quality of translation of the following contents.
1. Command Prompt
2. What is Perl?
3. Perl Installation
4. Master Perl Basic Syntax Quickly
By Ovid
on
December 12, 2013 5:00 PM
Whenever I present a talk on Test::Class or one of its variants, invariably someone asks me about parallelization. The reason is simple: I advocate running your xUnit tests in a single process instead of multiple processes, but it's hard to run tests in parallel when they're already forced into a single process.
For Test::Class, this means using separate *.t tests for every test class versus using a single *.t test and Test::Class::Load.
I am working on making parallel tests possible with Test::Class::Moose, and while I have test classes running in parallel, the confused is output (yes, that was deliberate). I know how to solve this using only publicly exposed APIs, but there are some tricky bits. I thought about asking for a TPF grant, but since most don't use xUnit style testing, the value seems marginal. Plus, I am on the Board of Directors for the Perl Foundation and that can look like a conflict of interest. Hence, my slow work in this area.
That being said, it's worth doing the math and asking ourselves where we get the greatest gain.
I created WordPress::Grep (or in GitHub) as a way to do power searches through my WordPress databases. I've often wanted a tool that could search with Perl patterns or arbitrary code to find odd CSS uses, check links, and all sorts of other things. I didn't see an easy way to do the things I wanted with WordPress::API, which seems more of an authoring tool than an administration or editing tool.
Having some time after patch -p1 in Paris, I started to work on this. After dealing with the horror of the PHP front end, I was surprised at how easy I got something working--the database setup isn't that bad. Now I have a basic tool that I use like this:
% wpgrep --host ... --user ... --database ... --regex ...
I've got a good start and it's doing what I need for now, but there are other things on my mind:
I maintain Term::ReadPassword::Win32 that has a POD file in Japanese. Now it got 2 bug reports for the Japanese POD, but even though both Japanese and Hungarian write their family name first, I don't know Japanese that well.... To say the least.
I am looking for a nice person who would check if the content of that files is still relevant. Convert it to utf8 and fix the two bugs reports related to that file. (See the bug reports and the GitHub repo linked from the above page.)
Inspired by a recent Perl advent article, I'm migrating my CPAN distributions from using Locale::Maketext to Locale::TextDomain.
Pros:
- I get to use all the available gettext tools (for scanning translateable strings, for merging and updating them to each translation file, specialized text editors for editing translation, etc). This is the definitely nicest thing about the migration. With David Wheeler's Dist::Zilla plugin, the workflow is basically 'dzil msg-scan', 'dzil msg-merge', and update translations (the plugin will do 'dzil msg-compile' for you during build).
- I no longer need to create project (translation) classes. I've always disliked having to do that, especially if my module or application is not OO.
- I get named parameters for values. Instead of having to write [_1], [_2], etc, I can now use {foo}, {bar} instead. Translation text become clearer.
Cons:
By jarich
on
December 11, 2013 11:32 AM
Hao Wu provided a great comment showing how I could solve exercise one using sum from List::Util and grep. I'd considered sum but utilzed false laziness and didn't use it. I'd also considered grep, but did not immediately hit upon the elegant solution that Hao suggested and so went with a more verbose solution.
So, here are some new solutions.
Perl 5:
use v5.14;
use List::Util qw(sum);
my $max = (shift || 1000) - 1;
# For each number, collect it if it is a multiple of 3 or 5 (where % returns false)
my @multiples = grep { not $_ % 5 && $_ % 3 } 1 .. $max;
# and we're done.
say "My multiples are: @multiples";
say "Total: ", sum @multiples;
Short, elegant, more obviously correct. What's not to love?
Perl 5i:
use perl5i::2;
my $max = (shift || 1000) - 1;
# For each number, collect it if it is a multiple of 3 or 5 (where % returns false)
my @multiples = grep { not $_ % 5 && $_ % 3 } 1 .. $max;
# and we're done.
say "My multiiples are: @multiples";
say "Total: ", @multiples->sum;
By Ovid
on
December 11, 2013 11:16 AM
Not Perl related, but I suspect some folks may appreciate this.
Today after a nasty mistake on the command line involving find and rm, I discovered that I deleted a number of files I didn't mean to delete, including some hidden files. Oops! I opened my Time Machine backup, only to discover that it doesn't show hidden files. However, it turns out that you can use that to show hidden files so long as your main system shows hidden files. I'm using OS X Mavericks, so I dropped the following bash script into my bin folder and named it togglehidden. Running this from the command line will toggle showing hidden files in the Finder on or off.
#!/bin/bash
is_shown=$(defaults read com.apple.finder AppleShowAllFiles)
if [ $is_shown != "TRUE" ]; then
echo Showing hidden files
defaults write com.apple.finder AppleShowAllFiles TRUE
else
echo Hiding hidden files
defaults write com.apple.finder AppleShowAllFiles FALSE
fi
killall Finder
Use at your own risk!
By Davs
on
December 11, 2013 9:01 AM
Hi!
Today I'd like to show you my testing setup which involves database testing. Hopefully it can help someone out or maybe someone could suggest me better ways of doing things.
First of all, having all the tests in the root of the 't/' directory got too messy, so I'm using mostly the same directory structure in my 't/' directory, as I have in my 'lib/' directory for the ease of navigation. Let's say this is the 'lib/' tree:
- lib/
- ????MyApp.pm
- ????MyApp/
- ????????MyModule.pm
then my 't/' directory would have the following layout:
- t/
- ????MyApp/
- ????????0001-MyApp_first_test.t
- ????????0002-MyApp_second_test.t
- ????????MyModule/
- ????????????0001-MyModule_first_test.t
- ????????????0002-MyModule_second_test.t
Because of the nested structure it would be messy to add the 'use lib' statement into the testfiles themselves to use my 'lib/' directory, so I give it as a parameter to prove. I run all my tests from the 't/' directory, so for the ease of use I created a 't/prove'