http://www.perlmonks.org?node_id=662072


in reply to Re: Short quines
in thread Short quines

If you use <code> tags your quine becomes much simpler:
use strict; use LWP; use HTTP::Request; my $ua = LWP::UserAgent::new ('LWP::UserAgent'); LWP::UserAgent::agent ($ua, 'Mozilla/5.0'); my $url = "http://www.perlmonks.org/?displaytype=displaycode;node_id=6 +62072"; my $request = HTTP::Request::new ('HTTP::Request', GET => $url); my $response = LWP::UserAgent::request ($ua, $request); print $response->content;
Also, you don't break formatting for replies to your node.

Edit: I think you want a question mark after dot-star. Otherwise it's q-positively trivial for me to break your code.

Edit2: I just realized that, if you put a question mark after dot-star, the end of your regex matches itself. But there are ways around that.

Replies are listed 'Best First'.
Re^3: Short quines
by ambrus (Abbot) on Jan 12, 2008 at 18:26 UTC

    As the title of this thread is "short quines", let me shorten that code a bit.

    use LWP::Simple;getprint"http://tinyurl.com/ynp5kp"

    Update: fixed code. It should now work.

    Update 2012-05-24:</c> see also Usually J.A.P.H..

Re^3: Short quines
by Snarius (Sexton) on Jan 12, 2008 at 19:21 UTC
    I tried using <code. It renders > as & gt; or something. I actually tried to eliminate the >'s from my code, which is why there are lines like LWP::UserAgent::request ($ua, $request); instead of $ua->request ($request);.

      I'm quite sure that the displaytype=displaycode cgi argument makes perlmonks return the code as plain text, not HTML, so the angle brackets shouldn't be a problem.

      Let me try.

      use warnings; use strict; my $u = "http://perlmonks.com/?node_id=662172;displaytype=displaycode" +; use LWP; print LWP::UserAgent->new->get($u)->content;