p0: thanks chris for more 'academic' views of the quine idea { I will confess as an approach it just seems silly.... }

p1: the q^...^ trick is not one I have used, it looks way
too much like bad ascii art... 8-)

p2: I likewise have not used the 'eval' in this context but
in the more traditional eval { .... }

On Tuesday, Mar 18, 2003, at 05:08 US/Pacific, Ken Williams wrote:
[..]

Variables $c and $t are undeclared, so the eval fails when they're encountered.


-Ken

OOF! why didn't I see that!


I could see that the $s was coming "down from above"
but had not paused to think about the $t and $c not
be declared, and hence getting neither a run time error
and obviously no compile time error....

It was dying silently inside of the 'eval'????

hence

        #!/usr/bin/perl -w
        use strict;
        our $s='our $c = chr(39);
        our $t = q^#!/usr/bin/perl -w
        use strict;
        our $s=^.$c.$s.$c.
        q^;eval $s;^."\n";print $t
        ###             execute-me          ####
        ###                                 ####
        ';
        eval $s;

self replicates as a quine...
But will not work with trying to have

        #!/usr/bin/perl -w
        ####$s='$c = chr(39);
        use strict;

since the "'" there will break up the assignment
for $t....

So while clearly still a 'silly problem' it at least
does illustrate a few tricks I might not have considered.

ciao
drieux

---



Reply via email to