Narcissist: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: removed superfluous blank lines. -- ~~~~ |
m →{{header|Perl 6}}: Use nested quoting delimiters. |
||
Line 137: | Line 137: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
For the narcissist to work you must be very careful with whitespace. The presented version works if it is stored as a file of exactly one line terminated by a |
For the narcissist to work you must be very careful with whitespace. The presented version works if it is stored as a file of exactly one line terminated by a newline character. |
||
Note |
Note how the code takes advantage of Perl 6's ability to nest quoting delimiters. |
||
<lang perl6>my $self=q |
<lang perl6>my $self=q{say slurp() eq 'my $self=q{'~$self~'}; eval($self);'~10.chr ?? 'Beautiful!' !! 'Not my type.'}; eval($self); |
||
</lang> |
</lang> |
||
{{out}} |
{{out}} |
||
<pre>$ rakudo narcissist.pl <narcissist.pl |
<pre>$ rakudo narcissist.pl <narcissist.pl |
||
Beautiful! |
|||
True |
|||
$ rakudo narcissist.pl <any-other-input. |
$ rakudo narcissist.pl <any-other-input.pl |
||
Not my type. |
|||
False |
|||
</pre> |
</pre> |
||