Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Calling a class constructor as a function on input arguments

by cwest (Friar)
on Jul 21, 2000 at 18:26 UTC ( #23583=note: print w/ replies, xml ) Need Help??


in reply to Calling a class constructor as a function on input arguments

I need more info about the context of the code you're going to write.

However, here's a possible solution:

my $os = eval "\\&FTP::Session::${^O}->new"; my %constor = ( $^O => $os );
I'm pretty sure that's what you're looking for.

Yes, the first argument is the package name, that's why constructors could look like this:

sub new { bless {}, shift }; # which is equivalent to this sub new { my $class = shift @_; my $self = {}; my $ref = bless $self, $class; return $ref; } # Bless could actually be: bless {}, 'Package::Name';
Enjoy!
--
Casey


Comment on Re: Calling a class constructor as a function on input arguments
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://23583]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2014-09-18 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (120 votes), past polls