Hello All,
I have a problem at work I need to solve. I am toying with the idea
of creating a special purpose Perl module to store data on some of
clients. So I have written a little test/proof of concept/far from
complete module that looks like this:
package NOVA::Client;
use strict;
use Carp;
sub new
{
my ($class) = @_;
bless {
_count => $_[1],
_begin_dt => $_[2],
_end_dt => $_[3],
_days => $_[4],
_completed => $_[5],
}, $class
}
sub get_days {
return $_[0]->{_days};
}
1;
----------
My test program looks like this:
#!/usr/local/bin/perl -w
# program: t_client.pl
use strict;
use Carp;
use NOVA::Client;
my $client = NOVA::Client->new("1", "7-1-2005", "6-30-2006","365","1");
print "New Client Days: $client->get_days\n";
----------
But my output is this:
[/Users/ehughes/Projects/Perl] # perl t_client.pl
New Client Days: NOVA::Client=HASH(0x1801380)->get_days
I must be a lot brain tired because I am forgetting something. Can
anyone tell me where I went wrong?
Thanks,
Elton
MacOS X 10.4.7
Perl 5.8.6
maddingue@free.fr - 03 Aug 2006 22:59 GMT
> Hello All,
Hello,
[...]
> print "New Client Days: $client->get_days\n";
> ----------
[quoted text clipped - 7 lines]
> I must be a lot brain tired because I am forgetting something. Can
> anyone tell me where I went wrong?
I'd say that's because methods don't interpolate inside strings.
--
Sébastien Aperghis-Tramoni
Close the world, txEn eht nepO.
Sherm Pendley - 03 Aug 2006 23:07 GMT
> print "New Client Days: $client->get_days\n";
> ----------
[quoted text clipped - 7 lines]
> I must be a lot brain tired because I am forgetting something. Can
> anyone tell me where I went wrong?
Perl is interpolating the value of $client into your string instead
of the value returned by $client->get_days.
Try this instead:
print "New Client Days: ", $client->get_days, "\n";
sherm--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Elton Hughes - 03 Aug 2006 23:41 GMT
Thanks Sebastien and Sherm!
That was the problem alright. Silly error on my part.
Thank you again for your time and response.
Elton
>> print "New Client Days: $client->get_days\n";
>> ----------
[quoted text clipped - 19 lines]
> Web Hosting by West Virginians, for West Virginians: http://wv-www.net
> Cocoa programming in Perl: http://camelbones.sourceforge.net