This document now resides at https://github.com/Ovid/Cor/blob/master/pod/perlclasstut.pod
This file contains 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 5.10.0; | |
use strict; | |
use warnings; | |
use Getopt::Long; | |
use Data::Dumper; | |
$Data::Dumper::Indent = 0; | |
$Data::Dumper::Terse = 1; |
This file contains 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 Ovids::Debugger; | |
# vim: syntax=perl | |
=head1 NAME | |
.perldb - Customize your Perl debugger | |
=head1 USAGE |
This file contains 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
# I needed to sure I was operating on pristine test databases | |
# every time my code called $test->schema (DBIx::Class and Test::Class::Moose). | |
# This handles that for me | |
package TestsFor::SeKreT { | |
use Test::Class::Moose; | |
use Less::Boilerplate; # gives me a sane version of Perl | |
use File::Copy qw(copy); | |
use File::Spec::Functions qw(catfile); | |
use SeKreT::Util::Data qw( | |
make_slug |
This file contains 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 App::Sqitch::Command::grep; | |
use 5.010; | |
use strict; | |
use warnings; | |
use utf8; | |
use App::Sqitch::X qw(hurl); | |
use Moo; | |
use App::Sqitch::Target; | |
use App::Sqitch::Types qw(Str Enum Target Bool); |
This is something that likely cannot be made into an RFC for the Perl language at this time because implementation would be greatly simplified when the Corinna object model is in core. For example, a base class for what is discussed might look like the following:
# Exception is a poor name for warnings, so a better name is warranted
class Exception :version(v0.1.0) {
# $message and $description might be from a messaging role
field $message :reader :param;
field $description :reader :param { "" };
This file contains 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 | |
# I decided it was time to learn PPR::X (Damian Conway's excellent regex-based Perl parser) | |
# | |
# This code is still heuristic in nature, but the challenge seemd fun. | |
# | |
# I thought it would be an interesting project to try to extract dependencies from | |
# Perl code. Thanks to `haj` giving me the clue needed to find a parsing error | |
use strict; |
This file contains 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 5.12.0; | |
use autodie; | |
use Carp; | |
use utf8::all; | |
use File::Spec::Functions qw(catfile catdir); | |
use File::Find::Rule; | |
use Getopt::Long; | |
use Capture::Tiny qw(capture); |
This file contains 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
class Counter { | |
# My::Cor::Attributes is using some hypothetical | |
# tool to extend Cor attributes. Because it's a | |
# `use` statement, it happens at compile time | |
use My::Cor::Attributes ':isa'; | |
has $count :reader :new :isa(PositiveInt) = 0; | |
method inc () { $count++ } | |
method dec () { $count-- unless 0 == $count } | |
} |