[BEGINNER]Storable::dclone question

soup_or_power_at_yahoo.com
Date: 03/25/05

  • Next message: Jim Gibson: "Re: [BEGINNER]Storable::dclone question"
    Date: 25 Mar 2005 14:46:35 -0800
    
    

    Can someone explain this code especially what it is doing with
    Storable::dclone? Thanks in advance

    sub new {
      my ($self, $hash) = @_;

      # ------------------------------------------------------
      # Create new hash ref/obj ref (Copy Constructor)
      # ------------------------------------------------------

      my $type = ref($self) || $self;
      my $obj = ( ref $self ) ? &Storable::dclone( $self ) : { };
      my $new = bless $obj, $type;

      # ------------------------------------------------------
      # Initialize properties (copy $hash into $new)
      # ------------------------------------------------------

      if ($hash && ref $hash) {
        while ( my ($key, $value) = each %$hash ) {
          $new->{$key} = $value if ! ref $value;
        }
      }

      return $new;
    }


  • Next message: Jim Gibson: "Re: [BEGINNER]Storable::dclone question"