Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 perusing the Monastery: (12)
As of 2015-07-06 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls