in reply to Find data point generating Error in Perl code

Sure
$ perl #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; open my $fake, '<', \"row\nrow\n\n\n"; while( <$fake> ){ my( $word ) = /(\w+)/; use warnings qw/ FATAL all /; eval { print "$word\n"; 1 } or dd({ OOPS => $@, line => $_ }); } __END__ row row { line => "\n", OOPS => "Use of uninitialized value \$word in concatenation (.) or s +tring at - line 9, <\$fake> line 3.\n", } { line => "\n", OOPS => "Use of uninitialized value \$word in concatenation (.) or s +tring at - line 9, <\$fake> line 4.\n", }
  • Comment on Re: Find data point generating Error in Perl code ( fatal warnings)
  • Download Code

Replies are listed 'Best First'.
Re^2: Find data point generating Error in Perl code ( fatal warnings)
by Anonymous Monk on Mar 17, 2015 at 01:01 UTC

    As a possibly interesting side note, just today a patch was submitted to P5P making FATAL warnings officially discouraged, due to multiple issues with them.

      As a possibly interesting side note, just today a patch was submitted to P5P making FATAL warnings officially discouraged, due to multiple issues with them.

      That is stupid

        That is stupid

        Nonsense! Now the author gets him name plastered in even more places. Late coming prima donnas need to be known too.

Re^2: Find data point generating Error in Perl code ( fatal warnings)
by kgherman (Novice) on Mar 17, 2015 at 19:17 UTC
    I'm trying to implement what you posted but I'm pretty lost: what is "$fake"? what is this code supposed to do? Thanks for all your help!

      I'm trying to implement what you posted but I'm pretty lost: what is "$fake"? what is this code supposed to do? Thanks for all your help!

      $fake is a filehandle , there is no physical file, its an in-memory file, so I called it $fake

      What this code does is demonstrate how to trap warnings by making them fatal, so that you can print out the current line of the file

      It does this by promoting warn to die which is caught with eval

      Its an answer to your question