autodie

Does the autodie-pragma have influence on the encoding?

99封情书 提交于 2020-01-19 09:43:26
问题 Why do I get after the "autodie" a different output? #!/usr/bin/env perl use warnings; use 5.012; use utf8; use open ':encoding(utf-8)'; use open ':std'; open my $fh, '>', 'test.txt' or die $!; say $fh 'käse'; close $fh; open my $fh1, '<', 'test.txt' or die $!; while ( my $row = readline( $fh1 ) ) { print $row; } close $fh1; use autodie; open my $fh2, '<', 'test.txt'; while ( my $row = readline( $fh2 ) ) { print $row; } close $fh2; # Output: # käse # käse 回答1: Unless someone comes in with a

Does the autodie-pragma have influence on the encoding?

烂漫一生 提交于 2020-01-19 09:42:32
问题 Why do I get after the "autodie" a different output? #!/usr/bin/env perl use warnings; use 5.012; use utf8; use open ':encoding(utf-8)'; use open ':std'; open my $fh, '>', 'test.txt' or die $!; say $fh 'käse'; close $fh; open my $fh1, '<', 'test.txt' or die $!; while ( my $row = readline( $fh1 ) ) { print $row; } close $fh1; use autodie; open my $fh2, '<', 'test.txt'; while ( my $row = readline( $fh2 ) ) { print $row; } close $fh2; # Output: # käse # käse 回答1: Unless someone comes in with a

How to use autodie with non-builtins?

你说的曾经没有我的故事 提交于 2019-12-10 03:45:10
问题 The autodie documentation hints that it is possible to use it for other functions than those built-ins which it can handle by default, but there are no clear examples how to do that in it. Specifically I would like to use it for the Imager module. A lot of the functions and methods of that can fail, and I would prefer if that wouldn't mean that my code will be littered with or die Imager|$image->errstr; phrases all over. Of course, if there's another way than using autodie to achieve that, I

Are there disadvantages to autodie?

醉酒当歌 提交于 2019-12-08 14:47:08
问题 Every now and again I see people on StackOverflow promote the use of autodie. But in the code here and elsewhere in the net I don't see autodie very often. Are there some disadvantages? Do I lose something when using autodie? (I have the idea of getting spoiled, when using autodie) 回答1: The autodie documentation lists a couple of gotchas and bugs you should be aware of. However, most of those are relatively minor, and also fixable in the long run. Other than that there are no real

Perl : Name “main::IN” used only once, but it is actually used

喜欢而已 提交于 2019-12-08 05:33:54
问题 I writing a short perl script that reads in a file. See tmp.txt : 1 gene_id "XLOC_000001"; gene_name "DDX11L1"; oId 1 gene_id "XLOC_000001"; gene_name "DDX11L1"; oId 1 gene_id "XLOC_000001"; gene_name "DDX11L1"; oId 1 gene_id "XLOC_000001"; gene_name "DDX11L1"; oId My perl program, convert.pl is : use warnings; use strict; use autodie; # die if io problem with file my $line; my ($xloc, $gene, $ens); open (IN, "tmp.txt") or die ("open 'tmp.txt' failed, $!\n"); while ($line = <IN>) { ($xloc,

Perl : Name “main::IN” used only once, but it is actually used

五迷三道 提交于 2019-12-07 11:27:28
I writing a short perl script that reads in a file. See tmp.txt : 1 gene_id "XLOC_000001"; gene_name "DDX11L1"; oId 1 gene_id "XLOC_000001"; gene_name "DDX11L1"; oId 1 gene_id "XLOC_000001"; gene_name "DDX11L1"; oId 1 gene_id "XLOC_000001"; gene_name "DDX11L1"; oId My perl program, convert.pl is : use warnings; use strict; use autodie; # die if io problem with file my $line; my ($xloc, $gene, $ens); open (IN, "tmp.txt") or die ("open 'tmp.txt' failed, $!\n"); while ($line = <IN>) { ($xloc, $gene) = ($line =~ /gene_id "([^"]+)".*gene_name "([^"]+)"/); print("$xloc $gene\n"); } close (IN) or

Does the autodie-pragma have influence on the encoding?

て烟熏妆下的殇ゞ 提交于 2019-11-28 09:05:59
Why do I get after the "autodie" a different output? #!/usr/bin/env perl use warnings; use 5.012; use utf8; use open ':encoding(utf-8)'; use open ':std'; open my $fh, '>', 'test.txt' or die $!; say $fh 'käse'; close $fh; open my $fh1, '<', 'test.txt' or die $!; while ( my $row = readline( $fh1 ) ) { print $row; } close $fh1; use autodie; open my $fh2, '<', 'test.txt'; while ( my $row = readline( $fh2 ) ) { print $row; } close $fh2; # Output: # käse # käse Unless someone comes in with a better reason, this looks like a bug with autodie in relation to the open pragma. Changing the last open to