From mst irc://irc.perl.org#dbix-class, 2016-12-27.
my $source = $schema->source('UserData');
my $new_source = $source->new(%$source, name => "user_data_${user_id}");
$schema->register_source('UserData_'.$user_id => $new_source);From mst irc://irc.perl.org#dbix-class, 2016-12-27.
my $source = $schema->source('UserData');
my $new_source = $source->new(%$source, name => "user_data_${user_id}");
$schema->register_source('UserData_'.$user_id => $new_source);| #!/usr/bin/env perl | |
| use 5.14.1; | |
| use warnings; | |
| package API { | |
| use Moose::Role; | |
| requires qw/store/; | |
| } |
| # For some reason, this was raising hell after adding | |
| # use namespace::autoclean; | |
| my $percent_captions = sub { | |
| my @left = @_[ 0 .. $#_ - 1 ]; | |
| my @right = @_[ 1 .. $#_ ]; | |
| return "< $_[0]%", pairwise {"$a to $b%"} @left, @right; | |
| }; | |
| my @pcts = ( 1, 5, 10, 25, 50, 75, 100 ); | |
| my @pct_captions = $percent_captions->(@pcts); |
I hereby claim:
To claim this, I am signing this object:
| #!/usr/bin/env/perl | |
| use 5.12.1; | |
| use warnings; | |
| use List::Util qw/sum/; | |
| my $customers = [ 10, 20, 30, 40, ]; | |
| my $churned = [ 2, 4, 3, 9, ]; | |
| my $churn_rate = 30 * sum(@$churned) / sum(@$customers); |
| #!/usr/bin/perl | |
| use strict; | |
| use warnings FATAL => qw( all ); | |
| use Net::Twitter::Lite::WithAPIv1_1; | |
| use Lingua::EN::Inflect qw(NO NUMWORDS); | |
| use HTML::Entities qw(encode_entities_numeric); | |
| use Try::Tiny; | |
| use lib '../files/lib'; |
| #!/usr/bin/env perl | |
| use 5.12.1; | |
| use warnings; | |
| eval { die 'hard' }; | |
| if ( @$ ) { | |
| say 'land softly'; | |
| } |
Javascript does not have block scope. It has function scope. So, it behaves much differently than perl and other languages with block scope.
E.g., this simple perl program creates then invokes an array of closures:
my @closures;
for ( 1 .. 3 ) {| # The legacy Lists API identified lists a `user` and `list_id`, which were the list | |
| # owners screen name and the list slug, respectively. | |
| # | |
| # The current list methods identify a list either by numeric ID (list_id => $list_id), | |
| # or by the owning user's screen_name and slug { owner_screen_name => $name, slug => $slug }, | |
| # or owning user's user ID as slug { owner_id => $id, slug => $slug }. | |
| # | |
| # So, for the most part, it's an easy transition. | |
| # | |
| # E.g., lines 251-255 |
| # Rate limit status example | |
| my $r = $nt->rate_limit_status; | |
| my $status_show_limit = $r->{resources}{'/statuses/show/:id'}; | |
| my $remaining = $status_show_limit->{remaining}; | |
| # Or, unpack limit, remaining and reset together: | |
| my ( $limit, $remaining, $reset ) = @{$r->{resources}{statuses}{'/statuses/show/:id'}}{qw/limit remaining reset/}; |