#!/usr/bin/perl use strict; use warnings; use feature 'say'; my $seq = 'AAGAATGCCAGTTTGTAAGTACTGACTTTGGAAAA'; my $x = 'A'; my $c = () = $seq =~ /$x/g; # $c is now 13 my $mod = 2; my ($quot, $rem) = (int $c / $mod, $c % $mod); say "Number of occurences: " . $c; say "Number of pairs: " . $quot; say "Remainder: " . $rem; __END__ $ perl test.pl Number of occurences: 13 Number of pairs: 6 Remainder: 1