What does this do (RHEL 7)? yum install perl-autodie
![]() |
0 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |
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 |
![]() |