This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| sub regex_from_list { | |
| my $re = join '|', map { quotemeta } @_; | |
| return qr/\b(?:$re)\b/i; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use Mojolicious::Lite; | |
| plugin 'Humane'; | |
| get '/' => sub { | |
| my $self = shift; | |
| $self->humane_stash( 'Welcome Back!' ); | |
| $self->render( 'simple' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| use PDL::Doc; | |
| use DDP output => shift; | |
| my $parser = PDL::Doc->new; | |
| $parser->scan(shift); | |
| p $parser; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| use Text::Balanced qw/extract_bracketed extract_delimited extract_multiple/; | |
| sub find_anchor_targets { | |
| my $html = shift; | |
| my @tags = extract_multiple( | |
| $html, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $app->helper( 'control_group' => sub { | |
| my $self = shift; | |
| my $contents = pop; | |
| my $label = xml_escape pop if @_; | |
| my $for = xml_escape pop if @_; | |
| my $return .= '<div class="control-group">'; | |
| if ($label) { | |
| $return .= '<label class="control-label"'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package MyApp; | |
| use Mojo::Base 'Mojolicious'; | |
| sub startup { | |
| my $self = shift; | |
| $self->helper( random => sub { rand } ); | |
| $self->routes->any( '/' => sub { | |
| my $c = shift; | |
| $c->render( text => $c->random ); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This does the same as Part 2 without doing the automagic loading. | |
| # DONT DO THIS REGULARLY, because part of the system might change, | |
| # the ->plugin loading abstracts you from that | |
| package MyApp; | |
| use Mojo::Base 'Mojolicious'; | |
| use Mojolicious::Plugin::MyPlugin; | |
| sub startup { | |
| my $self = shift; | |
| my $plugin = Mojolicious::Plugin::MyPlugin->new; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use Data::Dumper; | |
| sub write_data { | |
| my ($file, $data) = @_; | |
| open my $fh, '>', $file or die "Couldn't open $file: $!"; | |
| print $fh Dumper $data; | |
| } | |
| sub read_data { | |
| my ($file) = @_; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| ############################# | |
| # Getting the Forecast Data # | |
| ############################# | |
| use PDL; | |
| use Time::Piece; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use Mojolicious::Lite; | |
| my $pass = 'MyPassword'; | |
| any '/' => 'home'; | |
| any '/open' => sub { | |
| my $self = shift; |