Created
September 25, 2018 04:06
-
-
Save briandfoy/3f33f6ca4d35d29d13d45e7d108d1f96 to your computer and use it in GitHub Desktop.
(Perl) (mojolicious) A failed idea to make it easier to resolve files
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
| #!/Users/brian/bin/perls/perl-latest | |
| use v5.26; | |
| use utf8; | |
| use strict; | |
| use warnings; | |
| use Mojo::File; | |
| package Mojo::File::Role::parent { | |
| use Mojo::Base '-role'; | |
| use feature qw(signatures); | |
| no warnings qw(experimental::signatures); | |
| sub parent ($file, $dir) { $file->new( $dir, $file ) } | |
| sub rebase ($file, $dir) { | |
| $file->new( $dir, $file->basename ) | |
| } | |
| } | |
| my $dir = Mojo::File->new( 'Planet_Express/robots' ); | |
| say $dir->child( 'bender.txt' ); | |
| say Mojo::File->with_roles( '+parent' )->new( '/usr/local/bin/perl' )->rebase( $dir ); | |
| { | |
| my $file = | |
| Mojo::File | |
| ->with_roles( '+parent' ) | |
| ->new( 'bender.txt' ) | |
| ->parent( $dir ); | |
| say $file; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment