Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    my @unique = grep {$tally{$_} == 1} keys %tally;
    print "Unique keys:\n";
    print "$_\n" for sort @unique;
    
  2. or download this
      if ($tally{2} == 1) {
         print "2 is unique\n";
      }
    
  3. or download this
    my $a = '12345678901';
    my $cnt = $a =~ tr/1//;
    
    #In this case $cnt = 2, which means it is not unique