Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: What does the dash before hash assignment means?

by sundialsvc4 (Monsignor)
on Sep 03, 2013 at 12:13 UTC ( #1052092=note: print w/ replies, xml ) Need Help??


in reply to What does the dash before hash assignment means?

fun(-url => $httpRefer ); is not a “hash assignment.”   The => symbol in this case is equivalent to a comma.   Subroutine fun is being called with an argument-list containing two arguments:   -url, and the value of $httpRefer.

Some subroutines are written to recognize and to assign particular meanings to parameters which begin with a dash, e.g. to disambiguate user-chosen arbitrary strings which otherwise might match “real” parameters for the function.   (I, the author, decree that ... “Anything beginning with a dash is a literal.”)   But, that is up to their authors, not Perl itself.


Comment on Re: What does the dash before hash assignment means?
Re^2: What does the dash before hash assignment means?
by karlgoethebier (Curate) on Sep 03, 2013 at 13:50 UTC
    "...is not a hash assignment"

    It is.

    #!/usr/bin/env perl + use strict; use warnings; print fun(-nose =>'cuke') . qq(\n); sub fun { my %args = @_; return $args{-nose}; } __END__ karls-mac-mini:monks karl$ ./fun.pl cuke

    «The Crux of the Biscuit is the Apostrophe»

      Not really - the arguments to the function call construct a list:

      -nose =>'cuke' # even-sized list

      The hash assignment happens here:

      my %args = @_;

        OK, thats true.

        Thanks, Karl

        «The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-07-22 11:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (110 votes), past polls