in reply to Regarding Perl Class Object

The most burning issue to me is that your class is anonymous. The class and all its methods should be defined in a separate Whatever.pm file, which contains the first line "package Whatever;". The magic line with the -w followed by the use strict;pragma should instead be placed in the main program which itself should indeed be a .pl file - it won't get executed if placed within the .pm file where your class should be defined.

-M

Free your mind

Replies are listed 'Best First'.
Re^2: Regarding Perl Class Object
by Anno (Deacon) on Feb 22, 2007 at 13:26 UTC
    Sorry, but that reply is a little misleading.

    editi's class isn't anonymous, it's established in the default package main. While that is unusual, there's nothing wrong with it in principle. I do share the concern that it looks like the Author is not familiar with the standard way of establishing classes in dedicated packages.

    But to do that, it is by no means necessary to put the class code in an extra file. You can very well define a named class inside the main program. For tests and experiments you save a bit of potential hassle that way (in exchange for a smaller bit of different hassle).

    Thirdly, you are right that #!/path/to/perl -w isn't effective in a module file. But that isn't the modern way of switching on warnings anyway. use warnings works in main programs as well as in module files (and is needed in both, because its scope is lexical).

    Anno

    [update: corrected attribution]

    A reply falls below the community's threshold of quality. You may see it by logging in.