> You of course are aware of what a pain it is to apply this logic? Yes, which is exactly why you shouldn't mess around with references where they're not necessary. I suggest:
my $foo = Foo::Bar->new({path => $path}); or my $foo = Foo::Bar->new({data => $data}); Foo::Bar::new looks like: sub new { my $class = shift; my $args = shift; # or you could do # eval { %args = @_ }; croak ... if $@ my $self = {}; if($args->{data}){ $self->{data} = $args->{data}; } elsif($args->{path}){ open(my $fd, '<', $args->{path}) or die ...; $self->{data} = do { local $/; <$fd> }; } else { # informative error message die "Foo::Bar::new: blah blah blah RTFM"; } } ------8<------- This makes it very clear exactly what is going on, and prevents any confusion with what gets stringified where. Feel free to come up with a better name than "data" though. (I like it, others don't.) Regards, Jonathan Rockway
signature.asc
Description: OpenPGP digital signature