Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Is there a non-empty error quine in perl?

by hdb (Prior)
on Mar 09, 2014 at 17:58 UTC ( #1077591=note: print w/ replies, xml ) Need Help??


in reply to Is there a non-empty error quine in perl?

Is there a list of all possible error messages somewhere? I started to write this quine tester but now I have no idea how to feed it.

use strict; use warnings; use Sysadm::Install qw(tap); my $quine = 'Number found where operator expected at - line 1, near "l +ine 1" (Do you need to predeclare line?)'; my($stdout, $stderr, $rc) = tap "perl", "-e", $quine; print "stdout=$stdout\n", "stderr=$stderr\n", "rc=$rc\n"; if( $stdout eq '' and $stderr eq $quine ) { print "Found error quine!\n"; }

UPDATE: Forgot to thank saintmike for Re: Capturing both STDOUT, STDERR and exit status.


Comment on Re: Is there a non-empty error quine in perl?
Download Code
Replies are listed 'Best First'.
Re^2: Is there a non-empty error quine in perl?
by Corion (Pope) on Mar 09, 2014 at 18:12 UTC

    perldiag has them all, but you might need to fill in the placeholders with something tricky like __DATA__ maybe.

Re^2: Is there a non-empty error quine in perl?
by kcott (Abbot) on Mar 09, 2014 at 23:20 UTC

    In addition to what Corion says about placeholders, be aware that quoting, not shown in perldiag, may be added. For instance, that documentation shows this error message:

    Can't find string terminator %s anywhere before EOF

    Consider how that message is subtly changed by adding single quotes (around %s) in the first example below and double quotes in the second example.

    $ cat pm_error_quine Can't find string terminator " anywhere before EOF at pm_error_quine l +ine 1. $ perl pm_error_quine 1> /dev/null Can't find string terminator '"' anywhere before EOF at pm_error_quine + line 1. $
    $ cat pm_error_quine Can't find string terminator ` anywhere before EOF at pm_error_quine l +ine 1. $ perl pm_error_quine 1> /dev/null Can't find string terminator "`" anywhere before EOF at pm_error_quine + line 1. $

    -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1077591]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2015-07-28 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls