Replaced trim function with inline regex. Added encoding to slurp. Using utf8 in test file to fix tests.

master
dariog88a 2013-10-07 19:32:53 -03:00
parent 5988604d96
commit a1c8d901df
2 changed files with 4 additions and 10 deletions

View File

@ -18,15 +18,7 @@ attribution github => ['https://github.com/dariog88a','dariog88a'],
email => [ 'mailto:dariog88@gmail.com', 'dariog88' ],
twitter => ['http://twitter.com/dariog88','dariog88'];
#removes leading and trailing whitespace, and leaves just one blank between words
sub trim($) {
my $s = shift;
$s =~ s/ +/ /gs;
$s =~ s/^\s+|\s+$//g;
return $s;
}
my @shortcuts = share('shortcuts.csv')->slurp;
my @shortcuts = share('shortcuts.csv')->slurp(iomode => '<:encoding(UTF-8)');
handle remainder_lc => sub {
#replace all OS words with starting char
@ -39,7 +31,8 @@ handle remainder_lc => sub {
$search =~ /(W|M|L)/;
my $os = $1; #save OS char
$search =~ tr/[WML]//d; #remove all OS chars from search
$search = trim($search);
$search =~ tr/ / /s; #leave just one blank between words
$search =~ s/^\s+|\s+$//g; #trim
my $line;
foreach (@shortcuts) {

View File

@ -1,5 +1,6 @@
#!/usr/bin/env perl
use utf8;
use strict;
use warnings;
use Test::More;