Advertisement
tuldok89

"Desame"

Oct 19th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.45 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. my @a = (1, 2, 3, 4, 5);
  7. my @b = (1, 2, 3, 4, 5);
  8. my @c = (1, 2, 3, 4, 5);
  9.  
  10. sub check_same (\@\@) {
  11.     my ($ref_one, $ref_two) = @_;
  12.     return 0 unless @$ref_one == @$ref_two;
  13.    
  14.     for my $elem (0..$#$ref_one) {
  15.         return 0 unless $ref_one->[$elem] eq $ref_two->[$elem];
  16.     }
  17.    
  18.     return 1;
  19. }
  20.  
  21. print "\@a Is Desame To \@b\n" if check_same(@a, @b);
  22. print "\@a Is Desame To \@c\n" if check_same(@a, @c);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement