@matheusbsbs / matheus-bagliano / commits / 2388541a77
Fork 0

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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Sep 21, 2020 at 12:39 UTC 2388541a77540b8e2acfcf77904515ebb65ffcc5
1 file changed +3 -4
contrib/mw-to-git/t/test-gitmw.pl
+3 -4
@@ -25,7 +25,6 @@
25 use MediaWiki::API;
26 use Getopt::Long;
27 use DateTime::Format::ISO8601;
28 -use open ':encoding(utf8)';
28 use constant SLASH_REPLACEMENT => "%2F";
29
30 #Parsing of the config file
@@ -86,7 +85,7 @@ sub wiki_getpage {
85 # Replace spaces by underscore in the page name
86 $pagename =~ s/ /_/g;
87 $pagename =~ s/\//%2F/g;
89 - open(my $file, ">$destdir/$pagename.mw");
88 + open(my $file, ">:encoding(UTF-8)", "$destdir/$pagename.mw");
89 print $file "$content";
90 close ($file);
91
@@ -171,7 +170,7 @@ sub wiki_getallpagename {
170 cmlimit => 500 },
171 )
172 || die $mw->{error}->{code}.": ".$mw->{error}->{details};
174 - open(my $file, ">all.txt");
173 + open(my $file, ">:encoding(UTF-8)", "all.txt");
174 foreach my $page (@{$mw_pages}) {
175 print $file "$page->{title}\n";
176 }
@@ -184,7 +183,7 @@ sub wiki_getallpagename {
183 aplimit => 500,
184 })
185 || die $mw->{error}->{code}.": ".$mw->{error}->{details};
187 - open(my $file, ">all.txt");
186 + open(my $file, ">:encoding(UTF-8)", "all.txt");
187 foreach my $page (@{$mw_pages}) {
188 print $file "$page->{title}\n";
189 }