brunnock has asked for the wisdom of the Perl Monks concerning the following question:

On http://poe.perl.org/?POE_Cookbook/Web_Client, one of the demo scripts has the following line of code-

$kernel->post(ua => request => got_response => GET $url );

Is this a weird way of passing parameters or is this a POE quirk? Where can I find documentation regarding this? Thank you.

Replies are listed 'Best First'.
Re: Strange POE parameters
by rcaputo (Chaplain) on Sep 03, 2009 at 16:06 UTC
Re: Strange POE parameters
by AnomalousMonk (Archbishop) on Sep 03, 2009 at 18:34 UTC

    This is a weird way of passing parameters.

    As discussed in rcaputo's reply and the link(s) therefrom, it is another (and exactly equivalent) way of writing
        $kernel->post('ua', 'request', 'got_response', GET $url);
    except, IMO, less messy (for some definition of 'mess') and distracting.

    Another manifestation of this idiom is in the quasi-self-documentating
        return bless $objref => $class;
    which one might find in an object constructor and which might be read as 'bless object reference into class'.

Re: Strange POE parameters
by Narveson (Chaplain) on Sep 03, 2009 at 22:33 UTC

    It had never occurred to me to use the automatic quoting of barewords before the fat comma for anything other than a hash key. Apparently it works in the even-numbered list positions as well, but I find this usage confusing.

    Given this power of the fat comma, you could write

    use strict; my @days = (Mon=>Tue=>Wed=>Thu=>Fri=>);
    without getting a bareword warning. But please don't.

    The fat comma is recommended for use in natural pairs, mostly the key-value pairs of a hash, and the option to omit the quotes around the hash keys is widely thought to improve the presentation.

    Update: I stand corrected by the response below. Given that the post() parameters are not pairs, the following equivalent code would be standard formatting:

    $kernel->post( ua => 'request', got_response => GET $url, );

    $kernel->post( 'ua', 'request', 'got_response', GET $url, );