f



what is autodie?

What does this do (RHEL 7)?

yum install perl-autodie
0
T
11/21/2016 2:58:04 AM
comp.lang.perl.misc 33233 articles. 1 followers. brian (1246) is leader. Post Follow

4 Replies
458 Views

Similar Articles

[PageSpeed] 17

On Sunday, November 20, 2016 at 6:58:08 PM UTC-8, T wrote:
> What does this do (RHEL 7)?
> 
> yum install perl-autodie

perldoc autodie

or go to perdoc.org (type autodie in the search box)

You're welcome!


0
C
11/21/2016 3:49:36 AM
On 11/20/2016 07:49 PM, C.DeRykus wrote:
> perldoc autodie

I did not realize it was in perl doc.  I thought it was
an outside function for make P5 and P6 get along together.

      "autodie - Replace functions with ones that succeed
      or die with lexical scope"

Would you translate for me please?
0
T
11/21/2016 5:09:10 AM
On 21/11/2016 3:09 PM, T wrote:
> On 11/20/2016 07:49 PM, C.DeRykus wrote:
>> perldoc autodie
>
> I did not realize it was in perl doc.  I thought it was
> an outside function for make P5 and P6 get along together.
>
>      "autodie - Replace functions with ones that succeed
>      or die with lexical scope"
>
> Would you translate for me please?

autodie is a core pragma in Perl 5 that gives you error messages when
your file handling operations fail, without you having to write
explicit tests. For example,

   open(my $fh, '<', 'myfile.txt');

might fail, but with no test you won't know why your script isn't
working correctly. So good practice is to code like this:

   open(my $fh, '<', 'myfile.txt')
       or die "Cannot open file 'myfile.txt' for reading, stopped";

But that requires a lot of typing. So you can instead say:

   use autodie;
   ...
   open(my $fh, '<', 'myfile.txt');

and you *will* get an appropriate error message if the open operation
fails for some reason. Also applies to close.

AFAIK, this has nothing to do with Perl 6 -- but then I know nothing
about Perl 6.  :-)

HTH,

-- 
Athanasius  <°(((><
0
Athanasius
11/21/2016 6:56:07 AM
On 11/20/2016 10:56 PM, Athanasius wrote:
> On 21/11/2016 3:09 PM, T wrote:
>> On 11/20/2016 07:49 PM, C.DeRykus wrote:
>>> perldoc autodie
>>
>> I did not realize it was in perl doc.  I thought it was
>> an outside function for make P5 and P6 get along together.
>>
>>      "autodie - Replace functions with ones that succeed
>>      or die with lexical scope"
>>
>> Would you translate for me please?
>
> autodie is a core pragma in Perl 5 that gives you error messages when
> your file handling operations fail, without you having to write
> explicit tests. For example,
>
>   open(my $fh, '<', 'myfile.txt');
>
> might fail, but with no test you won't know why your script isn't
> working correctly. So good practice is to code like this:
>
>   open(my $fh, '<', 'myfile.txt')
>       or die "Cannot open file 'myfile.txt' for reading, stopped";
>
> But that requires a lot of typing. So you can instead say:
>
>   use autodie;
>   ...
>   open(my $fh, '<', 'myfile.txt');
>
> and you *will* get an appropriate error message if the open operation
> fails for some reason. Also applies to close.
>
> AFAIK, this has nothing to do with Perl 6 -- but then I know nothing
> about Perl 6.  :-)
>
> HTH,
>

That makes sense now.  Thank you!
0
T
12/9/2016 8:02:43 PM
Reply: