Often one knows beforehand which subclass of base class in which to initialize one's method. However, in my case, I want to call a constructor as a function of the operating system that I am on.
My first thought was to use a hash keyed on operating system name and store a reference to the new of each class as the value, ie:
%constructor = (
'MSWin32' => \&FTP::Session::Win32->new,
'HPUX' => \&FTP::Session::HPUX->new
)
Which brings up an additional question: since I am using an arrow in the above code instead of ::, will the first argument to the new be the package name? And will it only pass arguments if I had used ::?
Thanks for any help guys.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|