in reply to Can I do single-file, Object oriented perl?

All you need to do is define the main space with package main; ... you can see an example of that here: XML::Simple + Class::MethodMaker.

Are you sure, however, that you really want to bless scalars like that? You need to bless the reference, not the scalar itself. Perhaps you meant something like this instead:

my $self = { message => "This is dick", }; bless ($self, $class);

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Can I do single-file, Object oriented perl?
by gellyfish (Monsignor) on Jul 05, 2005 at 16:43 UTC

    bless(\$text, $class); is blessing a reference - and because bless returns the blessed value as well as acting directly upon it, the subroutine *does* return a blessed reference. See for example:

    my $foo = "bar"; print bless \$foo, "Test";

    Update: Apologies to jeffa, I got confused and was reading the wrong code when replying. The OP is indeed trying to bless a non-ref scalar, which would lead to an error: Can't bless non-reference value

    /J\