Skip to content

Instantly share code, notes, and snippets.

@libitte
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save libitte/9087406 to your computer and use it in GitHub Desktop.

Select an option

Save libitte/9087406 to your computer and use it in GitHub Desktop.
  • 配列の差分

@A - @B

my @A = qw(1 2 3 4 5 6 7 8 9);
my @B = qw(3 5 9);
 
my %cnt = ();
map { $cnt{$_}-- } @B;
my @array = grep { ++$cnt{$_} == 1 } @A;
  • Validation
Carp::croak($!)
	unless ($mode =~ /^R|W|BAK$/);

Carp::croak($!)
	unless any { $mode eq $_ } qw(W R BAK);
sub title {
  my $self = shift;
  if (@_) {
    $self->{title} = $_[0];
  }
  return $self->{title};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment