... my $chapter = shift; my $name = ( splitpath $chapter )[-1]; my $htmldir = catdir( qw( html ) ); $name =~ s/\.pod/\.html/; $name = catfile( $htmldir, $name ); open my $fh, '>:utf8', $name or die "Cannot write to '$name': $!\n"; print $fh; return $fh; }