Welcome, zizu1985, to the Monastery!

Please wrap your code within <code>code here</code> tags in your question. It makes it far more legible. As you can probably see, your code looks kind of indecipherable as is. See How do I post a question effectively? for details on formatting.

When formatted, it'd look (something) like this:

sub new { my ($class,$args_for) = @_; my $self = bless {} => $class; $self->_initialize($args_for); return $self; } sub new { my ($class,$args_for) = @_; my $self = bless {} , $class; $self->_initialize($args_for); return $self; }

To answer your question. First, note you're speaking of a comma (,) not a colon (:).

A => in Perl is often called a "fat" comma. It acts exactly the same way as a comma, with an additional feature. It will quote the left-hand-side of what's against it for you automatically. In your case above, it just acts like a normal comma, but here's an example of the additional feature in action:

# this will fail, because 'a' is unquoted my %hash = (a, 1); # same thing, but with fat-comma, which quotes 'a'. # this won't break things my %hash = (a => 1);

See the comma operator in perlop.

It would also be nice if you could please edit your question's title and replace "colon" with "comma". The title (which may make searching difficult), along with no code tags will have your question Considered (What is consideration?) for editing by the janitors.


In reply to Re: Difference between comma and => when calling subroutine by stevieb
in thread Difference between comma and => when calling subroutine by zizu1985

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.