だるろぐ

だるいぶろぐです

main: {} で動く理由

追記

壮絶な勘違いでしたコメント欄参照。暑さで脳がやられていたということにしてください。

sub main { } は良くかいてたけど、 main: { } とかにすると main() しなくても動く
にひりずむ::しんぷる - Re: Amazon のデカイ書影をダウンロードする

これ知らなかったのでperldoc読んだ。

% perldoc perlsub

  Subroutine Attributes

    A subroutine declaration or definition may have a list of attributes
    associated with it. If such an attribute list is present, it is broken
    up at space or colon boundaries and treated as though a "use attributes"
    had been seen. See attributes for details about what attributes are
    currently supported. Unlike the limitation with the obsolescent "use
    attrs", the "sub : ATTRLIST" syntax works to associate the attributes
    with a pre-declaration, and not just with a subroutine definition.

はいはいjapjap

(サブルーチン属性)


サブルーチン宣言や定義には、それと結び付けられた属性のリストを持たせることが出来ます。このような属性が合った場合、スペースかコロンを区切りとして分割され、 use attributes があったかのように扱われます。属性が現在対応している詳細については attributes を参照してください。古い use attrs の制限と違って、sub : ATTRLIST の文法は前方宣言でも動作し、サブルーチン定義だけではありません。
http://perldoc.jp/docs/perl/5.10.0/perlsub.pod


要点は

the "sub : ATTRLIST" syntax works to associate the attributes
with a pre-declaration, and not just with a subroutine definition.


sub : ATTRLIST の文法は前方宣言でも動作し、サブルーチン定義だけではありません。

これでいいのかな。