scratchpad
Revelation
For [jkeenan1]: Another solution would be to user perl 5.8's ability to open in memory files:
<code>
@input = qw/here is some input/;
my $imfile = join "\n",@input;
open(MEMORY,'+<', \$imfile) or die "Can't open memory file: $!";
# Then use IO::Handle or open to just override STDIN.
# To be comprehensive you could check the version of perl. If it's not high enough, you could require IO::String, to solve the problem, as well..
</code>
Something For me:
<code>
sub parameters {
return bless [ $_[0], $_[0]->{'params'} ], DummyNameSpace if want('OBJECT'); # Single Param.
return %{$_[0]->{'params'}; # This will create a
}
package DummyNameSpace;
our $AUTOLOAD;
sub isa {
$_[0]->[1]->{'isa'} = $_[1] if defined $_[1];
return $_[0]->[1]->{'isa'};
}
sub VERSION {
$_[0]->[1]->{'VERSION'} = $_[1] if defined $_[1];
return $_[0]->[1]->{'VERSION'};
}
sub can {
$_[0]->[1]->{'can'} = $_[1] if defined $_[1];
return $_[0]->[1]->{'can'};
}
sub AUTOLOAD {
ref(my $o = shift) or die; # don't mess with garbage collection
my $o1 = $o->[1];
( my $method = $AUTOLOAD ) =~ s{.*::}{};
if ( !$method ) { # AUTOLOAD AS PARAM.
$o1->{'AUTOLOAD'} = $_[0] if defined $_[0];
return $o1->{'AUTOLOAD'}
}
if ( $method =~ /^DESTROY$/ ) {
return if !defined wantarray;
$o1->{'DESTROY'} = $_[0] if defined $_[0];
return $o1->{'DESTROY'};
}
$o1->{$method} = $_[0] if defined $_[0] and return $o1->{$method};
undef $AUTOLOAD;
}
1;
</code>