Skip to content

Commit 2388541

Browse files
avargitster
authored andcommitted
remote-mediawiki tests: use inline PerlIO for readability
Replace the use of the "open" pragma with a three-arg open in the places that actually care about UTF-8, while leaving those that don't (the config parsing). Unlike the previous "encoding" pragma change this isn't needed for compatibility with anything. I just think it's easier to read code that has localized effects than code that changes global settings. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f80bc9 commit 2388541

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

contrib/mw-to-git/t/test-gitmw.pl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use MediaWiki::API;
2626
use Getopt::Long;
2727
use DateTime::Format::ISO8601;
28-
use open ':encoding(utf8)';
2928
use constant SLASH_REPLACEMENT => "%2F";
3029

3130
#Parsing of the config file
@@ -86,7 +85,7 @@ sub wiki_getpage {
8685
# Replace spaces by underscore in the page name
8786
$pagename =~ s/ /_/g;
8887
$pagename =~ s/\//%2F/g;
89-
open(my $file, ">$destdir/$pagename.mw");
88+
open(my $file, ">:encoding(UTF-8)", "$destdir/$pagename.mw");
9089
print $file "$content";
9190
close ($file);
9291

@@ -171,7 +170,7 @@ sub wiki_getallpagename {
171170
cmlimit => 500 },
172171
)
173172
|| die $mw->{error}->{code}.": ".$mw->{error}->{details};
174-
open(my $file, ">all.txt");
173+
open(my $file, ">:encoding(UTF-8)", "all.txt");
175174
foreach my $page (@{$mw_pages}) {
176175
print $file "$page->{title}\n";
177176
}
@@ -184,7 +183,7 @@ sub wiki_getallpagename {
184183
aplimit => 500,
185184
})
186185
|| die $mw->{error}->{code}.": ".$mw->{error}->{details};
187-
open(my $file, ">all.txt");
186+
open(my $file, ">:encoding(UTF-8)", "all.txt");
188187
foreach my $page (@{$mw_pages}) {
189188
print $file "$page->{title}\n";
190189
}

0 commit comments

Comments
 (0)