f0178d0784b6b6813357453d04c664b35781bd58
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / Helper / Model / DBIC / Schema.pm
1 package Catalyst::Helper::Model::DBIC::Schema;
2
3 use namespace::autoclean;
4 use Moose;
5 no warnings 'uninitialized';
6
7 our $VERSION = '0.63';
8 $VERSION = eval $VERSION;
9
10 use Carp;
11 use Tie::IxHash ();
12 use Data::Dumper ();
13 use List::Util 'first';
14 use MooseX::Types::Moose qw/Str HashRef Bool ArrayRef/;
15 use Catalyst::Model::DBIC::Schema::Types 'CreateOption';
16 use List::MoreUtils 'firstidx';
17 use Scalar::Util 'looks_like_number';
18 use File::Find 'finddepth';
19 use Try::Tiny;
20 use Cwd 'getcwd';
21 use Module::Runtime 'use_module';
22
23 =head1 NAME
24
25 Catalyst::Helper::Model::DBIC::Schema - Helper for DBIC Schema Models
26
27 =head1 SYNOPSIS
28
29   script/create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass \
30     [ create=dynamic | create=static ] [ traits=trait1,trait2... ] \
31     [ Schema::Loader opts ] [ dsn user pass ] \
32     [ other connect_info args ]
33
34 =head1 DESCRIPTION
35
36 Helper for the DBIC Schema Models.
37
38 =head2 Arguments:
39
40 C<CatalystModelName> is the short name for the Catalyst Model class
41 being generated (i.e. callable with C<$c-E<gt>model('CatalystModelName')>).
42
43 C<MyApp::SchemaClass> is the fully qualified classname of your Schema,
44 which might or might not yet exist.  Note that you should have a good
45 reason to create this under a new global namespace, otherwise use an
46 existing top level namespace for your schema class.
47
48 C<create=dynamic> instructs this Helper to generate the named Schema
49 class for you, basing it on L<DBIx::Class::Schema::Loader> (which
50 means the table information will always be dynamically loaded at
51 runtime from the database).
52
53 C<create=static> instructs this Helper to generate the named Schema
54 class for you, using L<DBIx::Class::Schema::Loader> in "one shot"
55 mode to create a standard, manually-defined L<DBIx::Class::Schema>
56 setup, based on what the Loader sees in your database at this moment.
57 A Schema/Model pair generated this way will not require
58 L<DBIx::Class::Schema::Loader> at runtime, and will not automatically
59 adapt itself to changes in your database structure.  You can edit
60 the generated classes by hand to refine them.
61
62 C<traits> is the list of traits to apply to the model, see
63 L<Catalyst::Model::DBIC::Schema> for details.
64
65 C<Schema::Loader opts> are documented in L<DBIx::Class::Schema::Loader::Base>
66 and some examples are given in L</TYPICAL EXAMPLES> below.
67
68 C<connect_info> arguments are the same as what L<DBIx::Class::Schema/connect>
69 expects, and are storage_type-specific. They are documented in
70 L<DBIx::Class::Storage::DBI/connect_info>. For DBI-based storage, these
71 arguments are the dsn, username, password, and connect options, respectively.
72 These are optional for existing Schemas, but required if you use either of the
73 C<create=> options.
74
75 username and password can be omitted for C<SQLite> dsns.
76
77 Use of either of the C<create=> options requires L<DBIx::Class::Schema::Loader>.
78
79 =head1 TYPICAL EXAMPLES
80
81 Use DBIx::Class::Schema::Loader to create a static DBIx::Class::Schema,
82 and a Model which references it:
83
84   script/myapp_create.pl model CatalystModelName DBIC::Schema \
85     MyApp::SchemaClass create=static dbi:mysql:foodb myuname mypass
86
87 Same, with extra connect_info args
88 user and pass can be omitted for sqlite, since they are always empty
89
90   script/myapp_create.pl model CatalystModelName DBIC::Schema \
91     MyApp::SchemaClass create=static dbi:SQLite:foo.db \
92     AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \
93     on_connect_do='["select 1", "select 2"]' quote_names=1
94
95 B<ON WINDOWS COMMAND LINES QUOTING RULES ARE DIFFERENT>
96
97 In C<cmd.exe> the above example would be:
98
99   script/myapp_create.pl model CatalystModelName DBIC::Schema \
100     MyApp::SchemaClass create=static dbi:SQLite:foo.db \
101     AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \
102     on_connect_do="[\"select 1\", \"select 2\"]" quote_names=1
103
104 Same, but with extra Schema::Loader args (separate multiple values by commas):
105
106   script/myapp_create.pl model CatalystModelName DBIC::Schema \
107     MyApp::SchemaClass create=static db_schema=foodb components=Foo,Bar \
108     exclude='^(wibble|wobble)$' moniker_map='{ foo => "FOO" }' \
109     dbi:Pg:dbname=foodb myuname mypass
110
111 Coderefs are also supported:
112
113   script/myapp_create.pl model CatalystModelName DBIC::Schema \
114     MyApp::SchemaClass create=static \
115     inflect_singular='sub { $_[0] =~ /\A(.+?)(_id)?\z/; $1 }' \
116     moniker_map='sub { join(q{}, map ucfirst, split(/[\W_]+/, lc $_[0])); }' \
117     dbi:mysql:foodb myuname mypass
118
119 See L<DBIx::Class::Schema::Loader::Base> for a list of options
120
121 Create a dynamic DBIx::Class::Schema::Loader-based Schema,
122 and a Model which references it (B<DEPRECATED>):
123
124   script/myapp_create.pl model CatalystModelName DBIC::Schema \
125     MyApp::SchemaClass create=dynamic dbi:mysql:foodb myuname mypass
126
127 Reference an existing Schema of any kind, and provide some connection information for ->config:
128
129   script/myapp_create.pl model CatalystModelName DBIC::Schema \
130     MyApp::SchemaClass dbi:mysql:foodb myuname mypass
131
132 Same, but don't supply connect information yet (you'll need to do this
133 in your app config, or [not recommended] in the schema itself).
134
135   script/myapp_create.pl model ModelName DBIC::Schema My::SchemaClass
136
137 =cut
138
139 has helper => (is => 'ro', isa => 'Catalyst::Helper', required => 1);
140 has create => (is => 'rw', isa => CreateOption);
141 has args => (is => 'ro', isa => ArrayRef);
142 has traits => (is => 'rw', isa => ArrayRef);
143 has schema_class => (is => 'ro', isa => Str, required => 1);
144 has loader_args => (is => 'rw', isa => HashRef);
145 has connect_info => (is => 'rw', isa => HashRef);
146 has old_schema => (is => 'rw', isa => Bool, lazy_build => 1);
147 has is_moose_schema => (is => 'rw', isa => Bool, lazy_build => 1);
148 has result_namespace => (is => 'rw', isa => Str, lazy_build => 1);
149 has components => (is => 'rw', isa => ArrayRef);
150
151 =head1 METHODS
152
153 =head2 mk_compclass
154
155 This is called by L<Catalyst::Helper> with the commandline args to generate the
156 files.
157
158 =cut
159
160 sub mk_compclass {
161     my ($package, $helper, $schema_class, @args) = @_;
162
163     my $self = $package->new(
164         helper => $helper,
165         schema_class => $schema_class,
166         args => \@args
167     );
168
169     $self->run;
170 }
171
172 sub BUILD {
173     my $self   = shift;
174     my $helper = $self->helper;
175     my @args   = @{ $self->args || [] };
176
177     $helper->{schema_class} = $self->schema_class;
178
179     @args = $self->_cleanup_args(\@args);
180
181     my ($traits_idx, $traits);
182     if (($traits_idx = firstidx { ($traits) = /^traits=(\S*)\z/ } @args) != -1) {
183         my @traits = split /,/ => $traits;
184
185         $self->traits(\@traits);
186
187         $helper->{traits} = '['
188             .(join ',' => map { qq{'$_'} } @traits)
189             .']';
190
191         splice @args, $traits_idx, 1, ();
192     }
193
194     if ($args[0] && $args[0] =~ /^create=(\S*)\z/) {
195         $self->create($1);
196         shift @args;
197
198         if (@args) {
199             $self->_parse_loader_args(\@args);
200
201             $helper->{loader_args} = $self->_build_helper_loader_args;
202         }
203     }
204
205     my $dbi_dsn_part;
206     if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) {
207         die
208 qq{DSN must start with 'dbi:' not '$dbi_dsn_part' (case matters!)}
209             if $dbi_dsn_part ne 'dbi';
210
211         $helper->{setup_connect_info} = 1;
212
213         $helper->{connect_info} =
214             $self->_build_helper_connect_info(\@args);
215
216         $self->_parse_connect_info(\@args);
217     }
218
219     $helper->{generator} = ref $self;
220     $helper->{generator_version} = $VERSION;
221 }
222
223 =head2 run
224
225 Can be called on an instance to generate the files.
226
227 =cut
228
229 sub run {
230     my $self = shift;
231
232     if ($self->create eq 'dynamic') {
233         $self->_print_dynamic_deprecation_warning;
234         $self->_gen_dynamic_schema;
235     } elsif ($self->create eq 'static') {
236         $self->_gen_static_schema;
237     }
238
239     $self->_gen_model;
240 }
241
242 sub _parse_loader_args {
243     my ($self, $args) = @_;
244
245     my %loader_args = $self->_read_loader_args($args);
246
247     while (my ($key, $val) = each %loader_args) {
248         next if $key =~ /^(?:components|constraint|exclude)\z/;
249
250         $loader_args{$key} = $self->_eval($val);
251         die "syntax error for loader args key '$key' with value '$val': $@"
252             if $@;
253     }
254
255     my @components = $self->_build_loader_components(
256         delete $loader_args{components},
257         $loader_args{use_namespaces},
258     );
259
260     $self->components(\@components);
261
262     for my $re_opt (qw/constraint exclude/) {
263         $loader_args{$re_opt} = qr/$loader_args{$re_opt}/
264         if exists $loader_args{$re_opt};
265     }
266
267     tie my %result, 'Tie::IxHash';
268
269     %result = (
270         relationships => 1,
271         use_moose => $self->is_moose_schema ? 1 : 0,
272         col_collision_map => 'column_%s',
273         (!$self->old_schema ? (
274                 use_namespaces => 1
275             ) : ()),
276         (@components ? (
277                 components => \@components
278             ) : ()),
279         (%loader_args ? %loader_args : ()),
280     );
281
282     $self->loader_args(\%result);
283
284     wantarray ? %result : \%result;
285 }
286
287 sub _read_loader_args {
288     my ($self, $args) = @_;
289
290     my %loader_args;
291
292     while (@$args && $args->[0] !~ /^dbi:/i) {
293         my ($key, $val) = split /=/, shift(@$args), 2;
294
295         if ($self->_is_struct($val)) {
296             $loader_args{$key} = $val;
297         } elsif ((my @vals = split /,/ => $val) > 1) {
298             $loader_args{$key} = \@vals;
299         } else {
300             $loader_args{$key} = $val;
301         }
302     }
303
304     # Use args after connect_info as loader args as well, because people always
305     # get the order confused.
306     my $i = 1;
307     if ($args->[0] =~ /sqlite/i) {
308         $i++ if $args->[$i] eq '';
309         $i++ if $args->[$i] eq '';
310     }
311     else {
312         $i += 2;
313     }
314
315     my $have_loader = try {
316         use_module('DBIx::Class::Schema::Loader::Base');
317         1;
318     };
319
320     if ($have_loader) {
321         while (defined $args->[$i]) {
322             $i++ while $self->_is_struct($args->[$i]);
323
324             last if not defined $args->[$i];
325
326             my ($key, $val) = split /=/, $args->[$i], 2;
327
328             if (not DBIx::Class::Schema::Loader::Base->can($key)) {
329                 $i++;
330                 next;
331             }
332
333             if ($self->_is_struct($val)) {
334                 $loader_args{$key} = $val;
335             } elsif ((my @vals = split /,/ => $val) > 1) {
336                 $loader_args{$key} = \@vals;
337             } else {
338                 $loader_args{$key} = $val;
339             }
340
341             splice @$args, $i, 1;
342         }
343     }
344
345     wantarray ? %loader_args : \%loader_args;
346 }
347
348 sub _build_helper_loader_args {
349     my $self = shift;
350
351     my $args = $self->loader_args;
352
353     tie my %loader_args, 'Tie::IxHash';
354
355     while (my ($arg, $val) = each %$args) {
356         if (ref $val) {
357             $loader_args{$arg} = $self->_data_struct_to_string($val);
358         } else {
359             $loader_args{$arg} = qq{'$val'};
360         }
361     }
362
363     \%loader_args
364 }
365
366 sub _build_loader_components {
367     my ($self, $components, $use_namespaces) = @_;
368
369     my @components = $self->old_schema && (not $use_namespaces) ? ()
370         : ('InflateColumn::DateTime');
371
372     if ($components) {
373         $components = [ $components ] if !ref $components;
374         push @components, @$components;
375     }
376
377     wantarray ? @components : \@components;
378 }
379
380 sub _build_helper_connect_info {
381     my ($self, $connect_info) = @_;
382
383     my @connect_info = @$connect_info;
384
385     my ($dsn, $user, $password) = $self->_get_dsn_user_pass(\@connect_info);
386
387     tie my %helper_connect_info, 'Tie::IxHash';
388
389     %helper_connect_info = (
390         dsn => qq{'$dsn'},
391         user => qq{'$user'},
392         password => qq{'$password'}
393     );
394
395     for (@connect_info) {
396         if (/^\s*{.*}\s*\z/) {
397             my $hash = $self->_eval($_);
398             die "Syntax errorr in connect_info hash: $_: $@" if $@;
399             my %hash = %$hash;
400
401             for my $key (keys %hash) {
402                 my $val = $hash{$key};
403
404                 if (ref $val) {
405                     $val = $self->_data_struct_to_string($val);
406                 } else {
407                     $val = $self->_quote($val);
408                 }
409
410                 $helper_connect_info{$key} = $val;
411             }
412
413             next;
414         }
415
416         my ($key, $val) = split /=/, $_, 2;
417
418         if ($key eq 'quote_char') {
419             $helper_connect_info{$key} = length($val) == 1 ?
420                 $self->_quote($val) :
421                 $self->_data_struct_to_string([split //, $val]);
422         } else {
423             $helper_connect_info{$key} = $self->_quote_unless_struct($val);
424         }
425     }
426
427     \%helper_connect_info
428 }
429
430 sub _build_old_schema {
431     my $self = shift;
432
433     return $self->result_namespace eq '' ? 1 : 0;
434 }
435
436 sub _build_is_moose_schema {
437     my $self = shift;
438
439     my @schema_parts = split '::', $self->schema_class;
440
441     my $result_dir = File::Spec->catfile(
442         $self->helper->{base}, 'lib', @schema_parts, $self->result_namespace
443     );
444
445     # assume yes for new schemas
446     return 1 if not -d $result_dir;
447
448     my $uses_moose = 1;
449
450     my $cwd = getcwd;
451
452     try {
453         finddepth(sub {
454             return if $File::Find::name !~ /\.pm\z/;
455
456             open my $fh, '<', $File::Find::name
457                 or die "Could not open $File::Find::name: $!";
458
459             my $code = do { local $/; <$fh> };
460             close $fh;
461
462             $uses_moose = 0 if $code !~ /\nuse Moose;\n/;
463
464             die;
465         }, $result_dir);
466     };
467
468     chdir $cwd;
469
470     return $uses_moose;
471 }
472
473 sub _build_result_namespace {
474     my $self = shift;
475
476     my @schema_parts = split '::', $self->schema_class;
477     my $schema_pm =
478         File::Spec->catfile($self->helper->{base}, 'lib', @schema_parts) . '.pm';
479
480     if (not -f $schema_pm) {
481         eval { use_module('DBIx::Class::Schema::Loader') };
482
483         return 'Result' if $@;
484
485         return (try { DBIx::Class::Schema::Loader->VERSION('0.05') }) ? 'Result' : '';
486     }
487
488     open my $fh, '<', $schema_pm or die "Could not open $schema_pm: $!";
489     my $code = do { local $/; <$fh> };
490     close $fh;
491
492     my ($result_namespace) = $code =~ /result_namespace => '([^']+)'/;
493
494     return $result_namespace if $result_namespace;
495
496     return '' if $code =~ /->load_classes/;
497
498     return 'Result';
499 }
500
501 sub _data_struct_to_string {
502     my ($self, $data) = @_;
503
504     local $Data::Dumper::Terse = 1;
505     local $Data::Dumper::Quotekeys = 0;
506     local $Data::Dumper::Sortkeys = 1;
507     local $Data::Dumper::Indent = 0;
508     local $Data::Dumper::Useqq = 1;
509
510     return Data::Dumper->Dump([$data]);
511 }
512
513 sub _get_dsn_user_pass {
514     my ($self, $connect_info) = @_;
515
516     my $dsn = shift @$connect_info;
517     my ($user, $password);
518
519     if ($dsn =~ /sqlite/i) {
520         ($user, $password) = ('', '');
521         shift @$connect_info while @$connect_info and $connect_info->[0] eq '';
522     } else {
523         ($user, $password) = splice @$connect_info, 0, 2;
524     }
525     
526     ($dsn, $user, $password)
527 }
528
529 sub _parse_connect_info {
530     my ($self, $connect_info) = @_;
531
532     my @connect_info = @$connect_info;
533
534     my ($dsn, $user, $password) = $self->_get_dsn_user_pass(\@connect_info);
535
536     tie my %connect_info, 'Tie::IxHash';
537     @connect_info{qw/dsn user password/} = ($dsn, $user, $password);
538
539     for (@connect_info) {
540         if (/^\s*{.*}\s*\z/) {
541             my $hash = $self->_eval($_);
542             die "Syntax errorr in connect_info hash: $_: $@" if $@;
543
544             %connect_info = (%connect_info, %$hash);
545
546             next;
547         }
548
549         my ($key, $val) = split /=/, $_, 2;
550
551         if ($key eq 'quote_char') {
552             $connect_info{$key} = length($val) == 1 ? $val : [split //, $val];
553         } elsif ($key =~ /^(?:name_sep|limit_dialect)\z/) {
554             $connect_info{$key} = $val;
555         } else {
556             $connect_info{$key} = $self->_eval($val);
557         }
558
559         die "syntax error for connect_info key '$key' with value '$val': $@"
560             if $@;
561     }
562
563     $self->connect_info(\%connect_info);
564
565     \%connect_info
566 }
567
568 sub _is_struct {
569     my ($self, $val) = @_;
570
571     return $val =~ /^\s*(?:sub|[[{])/;
572 }
573
574 sub _quote {
575     my ($self, $val) = @_;
576
577     return 'q{'.$val.'}';
578 }
579
580 sub _quote_unless_struct {
581     my ($self, $val) = @_;
582
583     $val = $self->_quote($val) if not $self->_is_struct($val);
584
585     return $val;
586 }
587
588 sub _eval {
589     my ($self, $code) = @_;
590
591     return $code if looks_like_number $code;
592
593     return $code if not $self->_is_struct($code);
594
595     return eval "{no strict; $code}";
596 }
597
598 sub _gen_dynamic_schema {
599     my $self = shift;
600
601     my $helper = $self->helper;
602
603     my @schema_parts = split(/\:\:/, $self->schema_class);
604     my $schema_file_part = pop @schema_parts;
605
606     my $schema_dir  = File::Spec->catfile(
607         $helper->{base}, 'lib', @schema_parts
608     );
609     my $schema_file = File::Spec->catfile(
610         $schema_dir, $schema_file_part . '.pm'
611     );
612
613     $helper->mk_dir($schema_dir);
614     $helper->render_file('schemaclass', $schema_file);
615 }
616
617 sub _gen_static_schema {
618     my $self = shift;
619
620     die "cannot load schema without connect info" unless $self->connect_info;
621
622     my $helper = $self->helper;
623
624     my $schema_dir = File::Spec->catfile($helper->{base}, 'lib');
625
626     try {
627         use_module('DBIx::Class::Schema::Loader')
628     }
629     catch {
630         die "Cannot load DBIx::Class::Schema::Loader: $_";
631     };
632
633     DBIx::Class::Schema::Loader->import(
634         "dump_to_dir:$schema_dir", 'make_schema_at'
635     );
636
637     make_schema_at(
638         $self->schema_class,
639         $self->loader_args,
640         [$self->connect_info]
641     );
642
643     require lib;
644     lib->import($schema_dir);
645
646     use_module($self->schema_class);
647
648     my @sources = $self->schema_class->sources;
649
650     if (not @sources) {
651         warn <<'EOF';
652 WARNING: No tables found, did you forget to specify db_schema?
653 EOF
654     }
655 }
656
657 sub _gen_model {
658     my $self = shift;
659     my $helper = $self->helper;
660
661     $helper->render_file('compclass', $helper->{file} );
662 }
663
664 sub _print_dynamic_deprecation_warning {
665     warn <<EOF;
666 ************************************ WARNING **********************************
667 * create=dynamic is DEPRECATED, please use create=static instead.             *
668 *******************************************************************************
669 EOF
670     print "Continue? [y/n]: ";
671     chomp(my $response = <STDIN>);
672     exit 0 if $response =~ /^n(o)?\z/;
673 }
674
675 sub _cleanup_args {
676     my ($self, $args) = @_;
677
678 # remove blanks, ie. someoned doing foo \  bar
679     my @res = grep !/^\s+\z/, @$args;
680
681 # remove leading whitespace, ie. foo \ bar
682     s/^\s*// for @res;
683
684     @res
685 }
686
687 =head1 SEE ALSO
688
689 General Catalyst Stuff:
690
691 L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
692 L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>,
693
694 Stuff related to DBIC and this Model style:
695
696 L<DBIx::Class>, L<DBIx::Class::Schema>,
697 L<DBIx::Class::Schema::Loader>, L<Catalyst::Model::DBIC::Schema>
698
699 =head1 AUTHOR
700
701 See L<Catalyst::Model::DBIC::Schema/AUTHOR> and
702 L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>.
703
704 =head1 COPYRIGHT
705
706 See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>.
707
708 =head1 LICENSE
709
710 This library is free software, you can redistribute it and/or modify
711 it under the same terms as Perl itself.
712
713 =cut
714
715 1;
716
717 __DATA__
718
719 =begin pod_to_ignore
720
721 __schemaclass__
722 package [% schema_class %];
723
724 use strict;
725 use base qw/DBIx::Class::Schema::Loader/;
726
727 __PACKAGE__->loader_options(
728     [%- FOREACH key = loader_args.keys %]
729     [% key %] => [% loader_args.${key} %],
730     [%- END -%]
731
732 );
733
734 =head1 NAME
735
736 [% schema_class %] - L<DBIx::Class::Schema::Loader> class
737
738 =head1 SYNOPSIS
739
740 See L<[% app %]>
741
742 =head1 DESCRIPTION
743
744 Dynamic L<DBIx::Class::Schema::Loader> schema for use in L<[% class %]>
745
746 =head1 GENERATED BY
747
748 [% generator %] - [% generator_version %]
749
750 =head1 AUTHOR
751
752 [% author.replace(',+$', '') %]
753
754 =head1 LICENSE
755
756 This library is free software, you can redistribute it and/or modify
757 it under the same terms as Perl itself.
758
759 =cut
760
761 1;
762
763 __compclass__
764 package [% class %];
765
766 use strict;
767 use base 'Catalyst::Model::DBIC::Schema';
768
769 __PACKAGE__->config(
770     schema_class => '[% schema_class %]',
771     [% IF traits %]traits => [% traits %],[% END %]
772     [% IF setup_connect_info %]connect_info => {
773         [%- FOREACH key = connect_info.keys %]
774         [% key %] => [% connect_info.${key} %],
775         [%- END -%]
776
777     }[% END %]
778 );
779
780 =head1 NAME
781
782 [% class %] - Catalyst DBIC Schema Model
783
784 =head1 SYNOPSIS
785
786 See L<[% app %]>
787
788 =head1 DESCRIPTION
789
790 L<Catalyst::Model::DBIC::Schema> Model using schema L<[% schema_class %]>
791
792 =head1 GENERATED BY
793
794 [% generator %] - [% generator_version %]
795
796 =head1 AUTHOR
797
798 [% author.replace(',+$', '') %]
799
800 =head1 LICENSE
801
802 This library is free software, you can redistribute it and/or modify
803 it under the same terms as Perl itself.
804
805 =cut
806
807 1;
808 __END__
809 # vim:sts=4 sw=4: