[Pdx-pm] Changing contructors w/o breaking compat.

Joshua Hoblitt jhoblitt at ifa.hawaii.edu
Fri Oct 25 21:45:39 CDT 2002

I was using Net::Ping the other day and became irritated with the contructor.  It would be fairly simple to just subclass it and add a own contructor but it got me thinking about how one would update the contructor and not break legacy code.

These are the first few lines of the constructor for Net::Ping.  Not only would it be much "prettier" to use a hash in the contructor there are several settings with must be set via a method call.  Of course I could just wait for perl6 then test 2nd param to see if it is a scalar or a slice but I'm assuming there must be some clever way of dealing with this now.

sub new
  my ($this,
      $proto,             # Optional protocol to use for pinging
      $timeout,           # Optional timeout in seconds
      $data_size,         # Optional additional bytes of data
      $device,            # Optional device to use
      ) = @_;



"Suppose you were an idiot. And suppose you were a member of Congress. But I repeat myself." -- Mark Twain

More information about the Pdx-pm-list mailing list