# Let's put a sequence in the $sequence
# I wrote it in three lines just for clarity!
$sequence = 'ACACGTACGTACTACGTAGCTACGACGATCGTACGTAGCACTGAATTCGGACG';
$sequence.= 'ACGTACGTACGTACGTAGCTCGATCGACGTACGTAGCTAGCACAGCTAGCTGA';
$sequence.= 'CGACGTAGCTACGTACGTCACGAATTCGCGATCGTACGTAGCTGTACGACTAG';

# I write here a cutting site
$EcoRI_site = 'GAATTC';

# the "split" function breaks a string ($sequence) 
# when finding a particular 'pattern' ($EcoRI_site)

@fragments = split(/$EcoRI_site/, $sequence);

$total = $#fragments + 1;
print "There are $total fragments.\n\n";

foreach $fragment (@fragments) {
  $i++;
  $length = length($fragment);
  print "Fragment 1: $length bp\n";
}