in reply to Re: perl grep
in thread perl grep

Ouch! I knew => was a comma in hash definition from the Llama but I didn't make the connection, sorry. But why would an author be using this form
unless (grep /regexp/ => @_) {...}
? Is it just easier to read than it would be using a simple comma? Or does the special property of interpreting the word to the left of => as a string have a beneficial effect? Thank you for your kind help.

Replies are listed 'Best First'.
Re: Re: Re: perl grep
by Corion (Patriarch) on Nov 22, 2003 at 17:27 UTC

    I think the fat comma is used here for aestethical reasons, as /regexp/ is applied to @_. I am also guilty of that sometimes. The notation makes sense sometimes, originally for key-value pairs in hashes :

    my %hash = ( foo => bar );

    You can also use it for the parameters if you have a subroutine that acts as a pipeline :

    sub transform { my ($source, $target) = @_; ... }; transform( 'input/start.file' => 'output/' );

    In that case, the "arrow" could be interpreted also in the mapping sense.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web