Questions tagged [autodie]

Replace functions with ones that succeed or die with lexical scope

9 questions
16
votes
1 answer

Does the autodie-pragma have influence on the encoding?

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, '<',…
sid_com
  • 24,137
  • 26
  • 96
  • 187
16
votes
4 answers

Are there disadvantages to autodie?

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…
sid_com
  • 24,137
  • 26
  • 96
  • 187
7
votes
3 answers

How to use autodie with non-builtins?

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…
Rörd
  • 6,556
  • 21
  • 27
7
votes
1 answer

Getting exceptions from IO::File?

The IO::File, IO::Socket::INET modules have some advantages over directly using perl's built-in IO functions, such as having explicit syntax to flush a handle. However, they seem to have some disadvantages over the built-in IO functions. For…
John Dough
  • 400
  • 3
  • 9
6
votes
3 answers

What is the difference between Perl modules autodie and Fatal?

The Perl modules autodie and Fatal seem to be doing similar things. What are the reasons for using one in preference to the other?
justintime
  • 3,601
  • 4
  • 22
  • 37
4
votes
1 answer

After scoped `no autodie` the program dies at `*STDOUT`

This program use warnings; use strict; use feature qw(say); { #use autodie; # all good when this is uncommented no autodie; } open my $OLDSTD, '>&', *STDOUT; #--> line 10 (program fails) open *STDOUT, '>', 'stdout.out'; say "$$…
zdim
  • 64,580
  • 5
  • 52
  • 81
3
votes
2 answers

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

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…
irritable_phd_syndrome
  • 4,631
  • 3
  • 32
  • 60
3
votes
1 answer

PERL Net::SFTP::Foreign autodie=>0 then 1

I'm writing a script that retrieves some files automatically once a day on some sftp server. The problem is this sftp server is not very reliable and sometimes the client have to retry a couple of times until opening the session successfully. I…
2
votes
2 answers

die like autodie

I use autodie to handle exceptions from built-ins. Unfortunately its scope is lexical, autodie does not work with methods. Is it possible to throw exceptions from my class methods so that they are handled in the same manner like autodie…
Gurunandan Bhat
  • 3,544
  • 3
  • 31
  • 43