diff Lib/IMPL/clone.pm @ 194:4d0e1962161c

Replaced tabs with spaces IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author cin
date Tue, 10 Apr 2012 20:08:29 +0400
parents 47dac58691ee
children
line wrap: on
line diff
--- a/Lib/IMPL/clone.pm	Tue Apr 10 08:13:22 2012 +0400
+++ b/Lib/IMPL/clone.pm	Tue Apr 10 20:08:29 2012 +0400
@@ -6,52 +6,52 @@
 our @EXPORT_OK = qw(&clone);
 
 {
-	my %handlers = (
-		HASH => sub {
-			my $class = blessed($_[0]);
-			
-			my $new = $_[1]->{ refaddr($_[0]) } = {};
-			while (my ($key,$val) = each %{$_[0]}) {
-				$new->{$key} = clone($val,$_[1]);
-			}
-			$class ? bless $new, $class : $new;
-		},
-		ARRAY => sub {
-			my $class = blessed($_[0]);
-			
-			my $new = $_[1]->{ refaddr($_[0]) } = [];
-			
-			push @$new, clone($_,$_[1]) foreach @{$_[0]};
-			
-			$class ? bless( $new, $class ) : $new;
-		},
-		SCALAR => sub {
-			my $class = blessed($_[0]);
-			
-			my $v = ${$_[0]};
-			$class ? bless \$v, $class : \$v;
-		},
-		REF => sub {
-			my $class = blessed($_[0]);
-			my $v;
-			my $new = $_[1]->{ refaddr($_[0]) } = \$v;
-			$v = clone ( ${$_[0]},$_[1] );
-			$class ? bless \$v, $class : \$v;
-			
-		},
-		REGEXP => sub {
-			$_[0];
-		}
-	);
-	
-	sub clone {
-		return unless @_;
-		
-		return $_[0] unless ref $_[0];
-		
-		return $_[1]->{refaddr($_[0])} || (UNIVERSAL::can($_[0],'_clone') || $handlers{reftype($_[0])} || sub { die "Unknown reftype " . reftype($_[0])} )->(@_);
-	}
-	
+    my %handlers = (
+        HASH => sub {
+            my $class = blessed($_[0]);
+            
+            my $new = $_[1]->{ refaddr($_[0]) } = {};
+            while (my ($key,$val) = each %{$_[0]}) {
+                $new->{$key} = clone($val,$_[1]);
+            }
+            $class ? bless $new, $class : $new;
+        },
+        ARRAY => sub {
+            my $class = blessed($_[0]);
+            
+            my $new = $_[1]->{ refaddr($_[0]) } = [];
+            
+            push @$new, clone($_,$_[1]) foreach @{$_[0]};
+            
+            $class ? bless( $new, $class ) : $new;
+        },
+        SCALAR => sub {
+            my $class = blessed($_[0]);
+            
+            my $v = ${$_[0]};
+            $class ? bless \$v, $class : \$v;
+        },
+        REF => sub {
+            my $class = blessed($_[0]);
+            my $v;
+            my $new = $_[1]->{ refaddr($_[0]) } = \$v;
+            $v = clone ( ${$_[0]},$_[1] );
+            $class ? bless \$v, $class : \$v;
+            
+        },
+        REGEXP => sub {
+            $_[0];
+        }
+    );
+    
+    sub clone {
+        return unless @_;
+        
+        return $_[0] unless ref $_[0];
+        
+        return $_[1]->{refaddr($_[0])} || (UNIVERSAL::can($_[0],'_clone') || $handlers{reftype($_[0])} || sub { die "Unknown reftype " . reftype($_[0])} )->(@_);
+    }
+    
 }
 
 1;