my $self = shift;
my $path = shift or _usage(q{$codeowners->write_to_filepath($filepath)});
- path($path)->spew_utf8([map { "$_\n" } @{$self->write_to_array('')}]);
+ path($path)->spew_utf8([map { "$_\n" } @{$self->write_to_array}]);
}
=method write_to_fh
=cut
sub write_to_fh {
- my $self = shift;
- my $fh = shift or _usage(q{$codeowners->write_to_fh($fh)});
+ my $self = shift;
+ my $fh = shift or _usage(q{$codeowners->write_to_fh($fh)});
+ my $charset = shift;
- for my $line (@{$self->write_to_array}) {
+ for my $line (@{$self->write_to_array($charset)}) {
print $fh "$line\n";
}
}
=cut
sub write_to_string {
- my $self = shift;
+ my $self = shift;
+ my $charset = shift;
- my $str = join("\n", @{$self->write_to_array}) . "\n";
+ my $str = join("\n", @{$self->write_to_array($charset)}) . "\n";
return \$str;
}
sub write_to_array {
my $self = shift;
- my $charset = shift // 'UTF-8';
+ my $charset = shift;
my @format;
}
}
- if ($charset) {
+ if (defined $charset) {
$_ = encode($charset, $_) for @format;
}
return \@format;