On 01/05/2014 05:40, Stefan Adams wrote:
> What do people think about move_to() creating the directory to the file
> that it will spurt rather than generating an error?
>
> sub move_to {
> my ($self, $to) = @_;
>
> make_path dirname($to); # Something like this?
> spurt $self->{content}, $to;
> return $self;
> }
>
>
> Or what about doing it in spurt()?
>
>
> sub spurt {
> my ($content, $path) = @_;
>
> make_path dirname($path); # Something like this?
>
> croak qq{Can't open file "$path": $!} unless open my $file, '>', $path;
> croak qq{Can't write to file "$path": $!} unless defined
> $file->syswrite($content); return $content; }
>
>
> What might be the harm in creating the path automatically rather than
> croaking because the path isn't there?
> Hum, I'd prefer that feature to be an option passed as argument to the functions rather than doing it automagically. -- Luc http://www.fiat-tux.fr/ Internet n'est pas compliqué, Internet est ce que vous en faites.
signature.asc
Description: OpenPGP digital signature
