#!/usr/bin/perl use warnings; use strict; my $f = 'chap 89.9'; if($f=~m/chap\s+?(\S+)/) { print " $1 \n", scalar @{[split//,$1]} -1; }