Passing Argument to a Perl Module Function

[email protected] ("KELVIN PHILIP")
Newsgroups perl.beginners
Message-ID <[email protected]>
Hi,

Will you please explain how to pass an argument to a subfunction defined in
a perl module? This is wahat i had tried; please correct me if I am wrong.

*Main:*

use MyModule::PrintMe;

$name = "John";
my $var = MyModule::PrintMe-> new($name);


*Module:

*package MyModule::PrintMe;

use Exporter;
use strict;

sub new {
        print("$_[0]\n");
}

1;


With this program, when I execute the main, it was not printing "John";
instead it was printing "MyModule::PrintMe"

Waiting to hear from you, thanking you in anticipation.

Regards, Kelvin.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.