Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Help choosing the most efficient, dependable condition(al)

by daxim (Chaplain)
on Nov 13, 2013 at 23:44 UTC ( #1062497=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Help choosing the most efficient, dependable condition(al)
in thread Help choosing the most efficient, dependable condition(al)

Not if send another header, namely "Vary". See the code update in Re: Help choosing the most efficient, dependable condition(al)

There's a lot to be gained by using a Web framework (you are familiar with CGI.pm, try Plack::Request/Plack::Response), where one doesn't have to care about newlines at all - the software handles the correct formatting for me. Short example: plackup -MPlack::Request -e'sub { my $req = Plack::Request->new(shift); return $req->new_response(200, [Content_Type => "text/html", Vary => "Accept"], [])->finalize }'

Doing the formatting manually and needing to get it correct is the real overhead. The work time of a programmer is expensive.


Comment on Re^3: Help choosing the most efficient, dependable condition(al)
Download Code
Re^4: Help choosing the most efficient, dependable condition(al)
by taint (Chaplain) on Nov 14, 2013 at 00:23 UTC
    In my humble defense daxim.

    When I use your revised edition, Perl throws:

    malformed header from script. Bad header=<?xml version="1.0" encoding= +": vary-test.cgi
    But, if I simply add an additional \n to each of the content-type lines:
    print "Content-Type: application/xhtml+xml; charset=UTF-8\n\n"; } else { print "Content-Type: text/html; charset=UTF-8\n\n";
    no errors thrown.

    I've been meaning to have a look at plackup. I've seen alot of people using it.

    Thanks for mentioning it.

    --Chris

    #!/usr/bin/perl -Tw
    use Perl::Always or die;
    my $perl_version = (5.12.5);
    print $perl_version;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-12-26 22:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls