in reply to Difference between comma and => when calling subroutine

Adding to post from stevieb. There is nothing special about bless vs any other built in function.

Here are some examples using print, to show the quoting ability before the =>

#!/usr/bin/perl use strict; use warnings; print "abc" => "xyz\n"; #prints abcxyz print abc => "xyz\n"; #prints abcxyz print "abc", "xyz\n"; #prints abcxyz (most natural formulation) #print abc, "xyz\n"; #prints No comma allowed after filehandle at C +:\Projects_Perl\testing\junk1.pl line 7.
I personally would highly recommend against using => where a comma "," is meant (i.e. your bless statement). And I would also highly recommend its use when defining elements of a hash or calling a function that expects a hash (occurs often in GUI code, -width => 5.0)

update: When I see =>, I think hash, even if I do the double quoting on the left side explictly, e.g. "key with embedded space" => 32

Replies are listed 'Best First'.
Re^2: Difference between comma and => when calling subroutine
by stevieb (Canon) on Mar 14, 2017 at 22:56 UTC

    Very good points I completely forgot to mention. ++