in reply to problems with reading __DATA__ from current package

Problems with Switch aside, your class will only support a single instance. On a subsequent attempt to create a new instance, DATA will be at eof. Since the data is static, you might cache it instead in a package variable, and use the Singleton pattern to return a single instance of States.

I'm guessing that you'll only be using a single instance, but someone who picks up your code later might not we aware of the implicit limitation, and will be surprised when their n+1st States object is empty.

Replies are listed 'Best First'.
Re: Re: problems with reading __DATA__ from current package
by perlguy (Deacon) on Jul 16, 2003 at 18:09 UTC

    Good tip. I will do so. I was so hung up on getting the first part to work, that... Well, you know.

    Thanks a bunch for the tips, everyone.