in reply to Re: Package declaration in code block
in thread Package declaration in code block

Hi Rolf,

thank you for the fast reply.

Is there an advantage in a classic package, one package per file?

Regards
McA

  • Comment on Re^2: Package declaration in code block

Replies are listed 'Best First'.
Re^3: Package declaration in code block
by tobyink (Canon) on Apr 23, 2014 at 16:49 UTC

    If you're posting example code, it's useful for everything to be in one self-contained example file, so that people can just copy and paste it into their editor and run it, rather than them having to create a directory called Foo and make a file in there called Bar.pm and paste some code in there, and then create another folder called Boo and make a file in there called Far.pm and paste more code in there, and then...

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

      That's a very good argument. I haven't thought about that.

      But this is the "More-than-one-package-per-file"-case. I was wondering if there is a reason to do so in a package per file.

      Regards
      McA

        I was wondering if there is a reason to do so in a package per file.

        Probably obedience to some style guide :)

        Or proper laziness -- if copy/paste works, why edit to unindent...

Re^3: Package declaration in code block
by dmitri (Priest) on Apr 24, 2014 at 02:46 UTC
    I use this form in my .t files when I need a quick class mock-up: it stands out more.