Apologies. Of course my production code does something like this:
my $self = { user_name => 'fubar', num_days => 0, }; bless ($self, $class);
I threw the tom/dick/harry example together from memory. I wanted to emphasize that I was defining 3 classes in the same file - something that other OO languages do not like.
If it works in the .pm, it'll work in the .pl. Another error must have been introduced.
Ikegami - I think you got it - but with one exception:
You have to include shebang (#!/usr/bin/perl) at the top of a .pl, but not at the top of a .pm file.
I took my working .pm file and tried to get it to work as a .pl and it threw errors. But I did not notice the error messages were BASH error messages instead of Perl messages. (duh)
I put shebang at the top of the script - and now it actually works. Thanks Monks!
In reply to Re^2: Can I do single-file, Object oriented perl?
by FatDog
in thread Can I do single-file, Object oriented perl?
by FatDog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |