Codebase list libio-all-perl / 774c924
Imported Upstream version 0.46 Nuno Carvalho 11 years ago
21 changed file(s) with 403 addition(s) and 72 deletion(s). Raw diff Collapse all Expand all
0 ---
1 version: 0.46
2 date: Wed Jul 25 17:35:44 PDT 2012
3 changes:
4 - Re-releasing to reclaim indexing from Alt-IO-All-new
5 ---
6 version: 0.45
7 date: Wed Jul 18 22:15:04 EDT 2012
8 changes:
9 - Added an example for ->assert and fixed the \E warnings on 5.16, courtesy shlomi fish
010 ---
111 version: 0.44
212 date: Wed Oct 5 18:11:27 EDT 2011
0 This software is copyright (c) 2011 by Ingy döt Net <ingy@cpan.org>.
0 This software is copyright (c) 2012 by Ingy döt Net <ingy@cpan.org>.
11
22 This is free software; you can redistribute it and/or modify it under
33 the same terms as the Perl 5 programming language system itself.
1111
1212 --- The GNU General Public License, Version 1, February 1989 ---
1313
14 This software is Copyright (c) 2011 by Ingy döt Net <ingy@cpan.org>.
14 This software is Copyright (c) 2012 by Ingy döt Net <ingy@cpan.org>.
1515
1616 This is free software, licensed under:
1717
1818 The GNU General Public License, Version 1, February 1989
1919
20 GNU GENERAL PUBLIC LICENSE
21 Version 1, February 1989
20 GNU GENERAL PUBLIC LICENSE
21 Version 1, February 1989
2222
2323 Copyright (C) 1989 Free Software Foundation, Inc.
24 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
24 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA
25
2526 Everyone is permitted to copy and distribute verbatim copies
2627 of this license document, but changing it is not allowed.
2728
28 Preamble
29 Preamble
2930
3031 The license agreements of most software companies try to keep users
3132 at the mercy of those companies. By contrast, our General Public
6667 The precise terms and conditions for copying, distribution and
6768 modification follow.
6869
69 GNU GENERAL PUBLIC LICENSE
70 GNU GENERAL PUBLIC LICENSE
7071 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
7172
7273 0. This License Agreement applies to any program or other work which
184185 of preserving the free status of all derivatives of our free software and
185186 of promoting the sharing and reuse of software generally.
186187
187 NO WARRANTY
188 NO WARRANTY
188189
189190 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
190191 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
206207 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
207208 POSSIBILITY OF SUCH DAMAGES.
208209
209 END OF TERMS AND CONDITIONS
210
211 Appendix: How to Apply These Terms to Your New Programs
210 END OF TERMS AND CONDITIONS
211
212 Appendix: How to Apply These Terms to Your New Programs
212213
213214 If you develop a new program, and you want it to be of the greatest
214215 possible use to humanity, the best way to achieve this is to make it
234235 GNU General Public License for more details.
235236
236237 You should have received a copy of the GNU General Public License
237 along with this program; if not, write to the Free Software Foundation,
238 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
238 along with this program; if not, write to the Free Software
239 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
240
239241
240242 Also add information on how to contact you by electronic and paper mail.
241243
269271
270272 --- The Artistic License 1.0 ---
271273
272 This software is Copyright (c) 2011 by Ingy döt Net <ingy@cpan.org>.
274 This software is Copyright (c) 2012 by Ingy döt Net <ingy@cpan.org>.
273275
274276 This is free software, licensed under:
275277
00 Changes
1 examples/create-cat-to.pl
12 inc/Module/Install.pm
23 inc/Module/Install/Base.pm
34 inc/Module/Install/Can.pm
2728 Makefile.PL
2829 MANIFEST This list of files
2930 META.yml
31 Notes/Design.md
3032 Notes/Design.st
3133 README
3234 t/absolute.t
22 author:
33 - 'Ingy döt Net <ingy@cpan.org>'
44 build_requires:
5 ExtUtils::MakeMaker: 6.42
5 ExtUtils::MakeMaker: 6.59
66 configure_requires:
7 ExtUtils::MakeMaker: 6.42
7 ExtUtils::MakeMaker: 6.59
88 distribution_type: module
9 generated_by: 'Module::Install version 1.01'
9 dynamic_config: 1
10 generated_by: 'Module::Install version 1.06'
1011 license: perl
1112 meta-spec:
1213 url: http://module-build.sourceforge.net/META-spec-v1.4.html
1516 name: IO-All
1617 no_index:
1718 directory:
19 - examples
1820 - inc
1921 - t
2022 recommends:
2325 IO::String: 1.08
2426 perl: 5.6.1
2527 resources:
26 homepage: http://github.com/ingydotnet/io-all-pm/tree
28 homepage: https://github.com/ingydotnet/io-all-pm/tree
2729 license: http://dev.perl.org/licenses/
28 repository: git://github.com/ingydotnet/io-all-pm.git
29 version: 0.44
30 repository:
31 type: git
32 url: git://github.com/ingydotnet/io-all-pm.git
33 web: https://github.com/ingydotnet/io-all-pm/tree
34 version: 0.46
0 use inc::Module::Package 'Ingy:modern 0.17';
0 use inc::Module::Package 'Ingy:modern 0.20';
11
22 requires 'IO::String' => '1.08';
33 recommends 'File::ReadBackwards';
0 # Introduction
1
2 This is a design document for an upcoming version of IO::All.
3
4 IO::All is a Perl module that attempts to make all Input/Output operations in
5 Perl, as simple and normal as possible. IO::All has been in existence since
6 2005. It is useful and somewhat extensible, but has a number of
7 inconsistencies, flaws and misgivings.
8
9 This document will propose a better way to do it, and will also discuss how to
10 move the current API forward to the new API.
11
12 # Basic Principles of how IO::All should work
13
14 * IO::All provides a single entry point function called `io`.
15 * `use IO::All` should make this function available in a lexical scope.
16 * Currently this scope is 'package' scope.
17 * Would be nice, but maybe not possible to have true lexical scope.
18 * The `io` function is custom to its scope
19 * The behavior it provides depends on the state of the scope
20 * The behavior it provides also depends on the arguments passed to `use
21 IO::All`
22 * `io` returns an IO::All object
23 * The IO::All object has no I/O capabilities
24 * Further method calls invoke a context, causing the IO::All object to
25 rebless itself it something useful like IO::All::File.
26 * Certain methods force a rebless
27 * `file(...), dir(...), socket(...), etc
28 * These methods are more or less hard-coded currently
29 * Options to `use IO::All` that begin with a `-`, cause a method to be called
30 on each new IO::All object.
31 * use IO::All -strict, -encoding => 'big5'; # causes:
32 * io('foo')->print('hi'); # to mean:
33 * io('foo')->strict->encoding('big5')->print('hi');
34 * IO::All operations generally return other IO::All objects
35 * Often they return themselves ($self) for chaining
36 * IO::All needs to be completely and consistently extensible
37 * The extensions that ship with IO-All should be the same as third party
38 extensions
39 * Extensions register capabilities with IO::All (tied to a scope)
40 * IO::All operations can be strict or loose. Strict always throws errors on
41 any possible error condition. Strict or loose should be determined by the
42 presence of `use strict` in the scope (possibly).
43 * IO::All currently uses a big set of overloaded operations by default. This
44 is loved by some and hated by others. It should probably be off by default
45 for 2.0.
46
47 # IO::All Extensions
48
49 Currently the extension API is fairly muddy. I would like the new API to
50 require something like this:
51
52 {
53 use strict;
54 use IO::All -overload;
55 use IO::All::PrintingPress;
56
57 my $io = io('path:to:printing:press#1');
58 # is ref($io), 'IO::All';
59 $io->print('IO::All'); # calls IO::All::PrintingPress::print
60 # is ref($io), 'IO::All::PrintingPress';
61 }
62
63 So you need to load any extensions that you want to use, within the scope that
64 you want them in. Exceptions are IO::All::File and IO::All::Dir, which are
65 automatically loaded, unless you say:
66
67 use IO::All -none;
68
69 Extensions can register 2 things:
70
71 1. Register a method (or methods) that will force a rebless in that class.
72 2. Register a regexp (or function) that will cause a rebless when the input
73 to io(...) matches.
74
75 These things are register according to the scope of the IO::All, so that the
76 `io` function will do the right things.
77
78 # Transition to the new API
79
80 It needs to be determined if the changes that need to be made are too
81 destructive to coexist with the current IO::All. That determination obviously
82 cannot be made until the new design is complete.
83
84 If it is not too destructive, IO::All and its extensions can be brought
85 forward.
86
87 If it is too destructive, here is one proposed solution:
88
89 Support IO::All 2 <options>;
90
91 The version '2' will load IO::All2 (or something) and no version will load the
92 old code.
93
94 It is important to assure that the old and new interfaces can coexist in the
95 same process space.
96
97 In the IO::All2 scenario, we would need to figure out if the current IO::All
98 extensions also needed forwarding.
99
156156
157157 with this:
158158
159 my $stuff < io "./mystuff";
159 my $stuff < io './mystuff';
160160
161161 And that is a good thing!
162162
684684 exists before the file is open. If the path does not exist, it is
685685 created.
686686
687 For example, here is a program called "create-cat-to" that outputs
688 to a file that it creates.
689
690 #!/usr/bin/perl
691
692 # create-cat-to.pl
693 # cat to a file that can be created.
694
695 use strict;
696 use warnings;
697
698 use IO::All;
699
700 my $filename = shift(@ARGV);
701
702 # Create a file called $filename, including all leading components.
703 io('-') > io->file($filename)->assert;
704
705 Here's an example use of it:
706
707 $ ls -l
708 total 0
709 $ echo "Hello World" | create-cat-to one/two/three/four.txt
710 $ ls -l
711 total 4
712 drwxr-xr-x 3 shlomif shlomif 4096 2010-10-14 18:03 one/
713 $ cat one/two/three/four.txt
714 Hello World
715 $
716
687717 * autoclose
688718
689719 By default, IO::All will close an object opened for input when EOF
0 #!/usr/bin/perl
1
2 # create-cat-to.pl
3 # cat to a file that can be created.
4
5 use strict;
6 use warnings;
7
8 use IO::All;
9
10 my $filename = shift(@ARGV);
11
12 # Create a file called $filename, including all leading components.
13 io('-') > io->file($filename)->assert;
33 use strict 'vars';
44 use vars qw{$VERSION};
55 BEGIN {
6 $VERSION = '1.01';
6 $VERSION = '1.06';
77 }
88
99 # Suspend handler for "redefined" warnings
22
33 use strict;
44 use Config ();
5 use File::Spec ();
65 use ExtUtils::MakeMaker ();
76 use Module::Install::Base ();
87
98 use vars qw{$VERSION @ISA $ISCORE};
109 BEGIN {
11 $VERSION = '1.01';
10 $VERSION = '1.06';
1211 @ISA = 'Module::Install::Base';
1312 $ISCORE = 1;
1413 }
2827 eval { require $mod; $pkg->VERSION($ver || 0); 1 };
2928 }
3029
31 # check if we can run some command
30 # Check if we can run some command
3231 sub can_run {
3332 my ($self, $cmd) = @_;
3433
3736
3837 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
3938 next if $dir eq '';
40 my $abs = File::Spec->catfile($dir, $_[1]);
39 require File::Spec;
40 my $abs = File::Spec->catfile($dir, $cmd);
4141 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
4242 }
4343
4444 return;
4545 }
4646
47 # can we locate a (the) C compiler
47 # Can our C compiler environment build XS files
48 sub can_xs {
49 my $self = shift;
50
51 # Ensure we have the CBuilder module
52 $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 );
53
54 # Do we have the configure_requires checker?
55 local $@;
56 eval "require ExtUtils::CBuilder;";
57 if ( $@ ) {
58 # They don't obey configure_requires, so it is
59 # someone old and delicate. Try to avoid hurting
60 # them by falling back to an older simpler test.
61 return $self->can_cc();
62 }
63
64 # Do we have a working C compiler
65 my $builder = ExtUtils::CBuilder->new(
66 quiet => 1,
67 );
68 unless ( $builder->have_compiler ) {
69 # No working C compiler
70 return 0;
71 }
72
73 # Write a C file representative of what XS becomes
74 require File::Temp;
75 my ( $FH, $tmpfile ) = File::Temp::tempfile(
76 "compilexs-XXXXX",
77 SUFFIX => '.c',
78 );
79 binmode $FH;
80 print $FH <<'END_C';
81 #include "EXTERN.h"
82 #include "perl.h"
83 #include "XSUB.h"
84
85 int main(int argc, char **argv) {
86 return 0;
87 }
88
89 int boot_sanexs() {
90 return 1;
91 }
92
93 END_C
94 close $FH;
95
96 # Can the C compiler access the same headers XS does
97 my @libs = ();
98 my $object = undef;
99 eval {
100 local $^W = 0;
101 $object = $builder->compile(
102 source => $tmpfile,
103 );
104 @libs = $builder->link(
105 objects => $object,
106 module_name => 'sanexs',
107 );
108 };
109 my $result = $@ ? 0 : 1;
110
111 # Clean up all the build files
112 foreach ( $tmpfile, $object, @libs ) {
113 next unless defined $_;
114 1 while unlink;
115 }
116
117 return $result;
118 }
119
120 # Can we locate a (the) C compiler
48121 sub can_cc {
49122 my $self = shift;
50123 my @chunks = split(/ /, $Config::Config{cc}) or return;
77150
78151 __END__
79152
80 #line 156
153 #line 236
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '1.01';
8 $VERSION = '1.06';
99 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
66 use base qw(Module::Install::Base);
77 use vars qw($VERSION);
88
9 $VERSION = '0.10';
9 $VERSION = '0.16';
1010
1111 sub githubmeta {
1212 my $self = shift;
1313 return unless $Module::Install::AUTHOR;
1414 return unless _under_git();
1515 return unless $self->can_run('git');
16 return unless my ($git_url) = `git remote show -n origin` =~ /URL: (.*)$/m;
16 my $remote = shift || 'origin';
17 return unless my ($git_url) = `git remote show -n $remote` =~ /URL: (.*)$/m;
1718 return unless $git_url =~ /github\.com/; # Not a Github repository
1819 my $http_url = $git_url;
1920 $git_url =~ s![\w\-]+\@([^:]+):!git://$1/!;
20 $http_url =~ s![\w\-]+\@([^:]+):!http://$1/!;
21 $http_url =~ s![\w\-]+\@([^:]+):!https://$1/!;
2122 $http_url =~ s!\.git$!/tree!;
22 $self->repository( $git_url );
23 $self->repository(
24 {
25 type => 'git',
26 url => $git_url,
27 web => $http_url,
28 },
29 );
2330 $self->homepage( $http_url ) unless $self->homepage();
2431 return 1;
2532 }
4653 'Github';
4754 __END__
4855
49 #line 108
56 #line 117
77
88 use vars qw{$VERSION @ISA $ISCORE};
99 BEGIN {
10 $VERSION = '1.01';
10 $VERSION = '1.06';
1111 @ISA = 'Module::Install::Base';
1212 $ISCORE = 1;
1313 }
214214 require ExtUtils::MakeMaker;
215215
216216 if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) {
217 # MakeMaker can complain about module versions that include
218 # an underscore, even though its own version may contain one!
219 # Hence the funny regexp to get rid of it. See RT #35800
220 # for details.
221 my $v = $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/;
222 $self->build_requires( 'ExtUtils::MakeMaker' => $v );
223 $self->configure_requires( 'ExtUtils::MakeMaker' => $v );
217 # This previous attempted to inherit the version of
218 # ExtUtils::MakeMaker in use by the module author, but this
219 # was found to be untenable as some authors build releases
220 # using future dev versions of EU:MM that nobody else has.
221 # Instead, #toolchain suggests we use 6.59 which is the most
222 # stable version on CPAN at time of writing and is, to quote
223 # ribasushi, "not terminally fucked, > and tested enough".
224 # TODO: We will now need to maintain this over time to push
225 # the version up as new versions are released.
226 $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 );
227 $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 );
224228 } else {
225229 # Allow legacy-compatibility with 5.005 by depending on the
226230 # most recent EU:MM that supported 5.005.
227 $self->build_requires( 'ExtUtils::MakeMaker' => 6.42 );
228 $self->configure_requires( 'ExtUtils::MakeMaker' => 6.42 );
231 $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 );
232 $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 );
229233 }
230234
231235 # Generate the MakeMaker params
240244 'all_from' if you prefer) in Makefile.PL.
241245 EOT
242246
243 $DB::single = 1;
244247 if ( $self->tests ) {
245248 my @tests = split ' ', $self->tests;
246249 my %seen;
411414
412415 __END__
413416
414 #line 541
417 #line 544
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '1.01';
8 $VERSION = '1.06';
99 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
150150 sub install_as_vendor { $_[0]->installdirs('vendor') }
151151
152152 sub dynamic_config {
153 my $self = shift;
154 unless ( @_ ) {
155 warn "You MUST provide an explicit true/false value to dynamic_config\n";
156 return $self;
157 }
158 $self->{values}->{dynamic_config} = $_[0] ? 1 : 0;
153 my $self = shift;
154 my $value = @_ ? shift : 1;
155 if ( $self->{values}->{dynamic_config} ) {
156 # Once dynamic we never change to static, for safety
157 return 0;
158 }
159 $self->{values}->{dynamic_config} = $value ? 1 : 0;
159160 return 1;
161 }
162
163 # Convenience command
164 sub static_config {
165 shift->dynamic_config(0);
160166 }
161167
162168 sub perl_version {
1515 use Module::Install::Base;
1616 use vars qw'@ISA $VERSION';
1717 @ISA = 'Module::Install::Base';
18 $VERSION = '0.29';
18 $VERSION = '0.30';
1919
2020 #-----------------------------------------------------------------------------#
2121 # XXX BOOTBUGHACK
5353 # plugin directive:
5454 my $module_install_plugin;
5555 my $module_package_plugin;
56 my $module_package_dist_plugin;
5657 # XXX ARGVHACK This @argv thing is a temporary fix for an ugly bug somewhere in the
5758 # Wikitext module usage.
5859 my @argv;
6566 $module_package_plugin = $self->_load_plugin($plugin_spec);
6667 $module_package_plugin->mi($module_install_plugin);
6768 $module_package_plugin->version_check($VERSION);
69 }
70 else {
71 $module_package_dist_plugin = $self->_load_dist_plugin($plugin_spec);
72 $module_package_dist_plugin->mi($module_install_plugin) if ref $module_package_dist_plugin;
6873 }
6974 # NOTE - This is the point in time where the body of Makefile.PL runs...
7075 return;
7984 }
8085 else {
8186 $module_install_plugin->_initial();
87 $module_package_dist_plugin->_initial() if ref $module_package_dist_plugin;
8288 $module_install_plugin->_main();
89 $module_package_dist_plugin->_main() if ref $module_package_dist_plugin;
8390 }
8491 };
8592 if ($@) {
100107 $module_package_plugin->final;
101108 $module_package_plugin->replicate_module_package;
102109 }
103 : $module_install_plugin->_final;
110 : do {
111 $module_install_plugin->_final;
112 $module_package_dist_plugin->_final() if ref $module_package_dist_plugin;
113 }
104114 }
105115 }
106116
122132
123133 # Find and load the author side plugin:
124134 sub _load_plugin {
125 my ($self, $spec) = @_;
135 my ($self, $spec, $namespace) = @_;
126136 $spec ||= '';
137 $namespace ||= 'Module::Package';
127138 my $version = '';
128139 $Module::Package::plugin_version = 0;
129140 if ($spec =~ s/\s+(\S+)\s*//) {
136147 ($spec =~ /^:(\w+)$/) ? ('Plugin', "Plugin::$1") :
137148 ($spec =~ /^(\S*\w):(\w+)$/) ? ($1, "$1::$2") :
138149 die "$spec is invalid";
139 $module = "Module::Package::$module";
140 $plugin = "Module::Package::$plugin";
150 $module = "${namespace}::${module}";
151 $plugin = "${namespace}::${plugin}";
141152 eval "use $module $version (); 1" or die $@;
142153 return $plugin->new();
154 }
155
156 # Find and load the user side plugin:
157 sub _load_dist_plugin {
158 my ($self, $spec, $namespace) = @_;
159 $spec ||= '';
160 $namespace ||= 'Module::Package::Dist';
161 my $r = eval { $self->_load_plugin($spec, $namespace); };
162 return $r if ref $r;
163 return;
143164 }
144165
145166 #-----------------------------------------------------------------------------#
216237 return if $WriteAll++;
217238 $self->WriteAll(@_);
218239 }
240
241 # Base package for Module::Package plugin distributed components.
242 package Module::Package::Dist;
243
244 sub new {
245 my ($class, %args) = @_;
246 bless \%args, $class;
247 }
248
249 sub mi {
250 @_ > 1 ? ($_[0]->{mi}=$_[1]) : $_[0]->{mi};
251 }
252
253 sub _initial {
254 my ($self) = @_;
255 }
256
257 sub _main {
258 my ($self) = @_;
259 }
260
261 sub _final {
262 my ($self) = @_;
263 }
264
265 1;
219266
220267 #-----------------------------------------------------------------------------#
221268 # Take a guess at the primary .pm and .pod files for 'all_from', and friends.
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '1.01';
8 $VERSION = '1.06';
99 @ISA = 'Module::Install::Base';
1010 $ISCORE = 1;
1111 }
55
66 use vars qw{$VERSION @ISA $ISCORE};
77 BEGIN {
8 $VERSION = '1.01';
8 $VERSION = '1.06';
99 @ISA = qw{Module::Install::Base};
1010 $ISCORE = 1;
1111 }
3030 # This is not enforced yet, but will be some time in the next few
3131 # releases once we can make sure it won't clash with custom
3232 # Module::Install extensions.
33 $VERSION = '1.01';
33 $VERSION = '1.06';
3434
3535 # Storage for the pseudo-singleton
3636 $MAIN = undef;
450450 }
451451
452452 sub _cmp ($$) {
453 _version($_[0]) <=> _version($_[1]);
453 _version($_[1]) <=> _version($_[2]);
454454 }
455455
456456 # Cloned from Params::Util::_CLASS
466466
467467 1;
468468
469 # Copyright 2008 - 2011 Adam Kennedy.
469 # Copyright 2008 - 2012 Adam Kennedy.
1414 use strict;
1515
1616 BEGIN {
17 $Module::Package::VERSION = '0.29';
17 $Module::Package::VERSION = '0.30';
1818 $inc::Module::Package::VERSION ||= $Module::Package::VERSION;
1919 @inc::Module::Package::ISA = __PACKAGE__;
2020 }
1212 use Symbol();
1313 use Fcntl;
1414
15 our $VERSION = '0.44';
15 our $VERSION = '0.46';
1616 our @EXPORT = qw(io);
1717
1818 #===============================================================================
7272 my $self = shift;
7373 my $method = shift;
7474 my $class_id = $self->autoload->{$method} || $method;
75 return "IO::All::\u$class_id" if $INC{"IO/All/\u$class_id\E.pm"};
75 my $ucfirst_class_name = 'IO::All::' . ucfirst($class_id);
76 my $ucfirst_class_fn = "IO/All/" . ucfirst($class_id) . ".pm";
77 return $ucfirst_class_name if $INC{$ucfirst_class_fn};
7678 return "IO::All::\U$class_id" if $INC{"IO/All/\U$class_id\E.pm"};
7779 require IO::All::Temp;
78 if (eval "require IO::All::\u$class_id; 1") {
79 my $class = "IO::All::\u$class_id";
80 if (eval "require $ucfirst_class_name; 1") {
81 my $class = $ucfirst_class_name;
8082 my $return = $class->can('new')
8183 ? $class
8284 : do { # (OS X hack)
83 my $value = $INC{"IO/All/\u$class_id\E.pm"};
84 delete $INC{"IO/All/\u$class_id\E.pm"};
85 my $value = $INC{$ucfirst_class_fn};
86 delete $INC{$ucfirst_class_fn};
8587 $INC{"IO/All/\U$class_id\E.pm"} = $value;
8688 "IO::All::\U$class_id";
8789 };
160160
161161 with this:
162162
163 my $stuff < io "./mystuff";
163 my $stuff < io './mystuff';
164164
165165 And that is a B<good thing>!
166166
706706 This method ensures that the path for a file or directory actually exists
707707 before the file is open. If the path does not exist, it is created.
708708
709 For example, here is a program called "create-cat-to" that outputs to a file
710 that it creates.
711
712 #!/usr/bin/perl
713
714 # create-cat-to.pl
715 # cat to a file that can be created.
716
717 use strict;
718 use warnings;
719
720 use IO::All;
721
722 my $filename = shift(@ARGV);
723
724 # Create a file called $filename, including all leading components.
725 io('-') > io->file($filename)->assert;
726
727 Here's an example use of it:
728
729 $ ls -l
730 total 0
731 $ echo "Hello World" | create-cat-to one/two/three/four.txt
732 $ ls -l
733 total 4
734 drwxr-xr-x 3 shlomif shlomif 4096 2010-10-14 18:03 one/
735 $ cat one/two/three/four.txt
736 Hello World
737 $
738
709739 =item * autoclose
710740
711741 By default, IO::All will close an object opened for input when EOF is