substr $string, 0, 30; # will extract UP TO the first 30 characters of the string. $string =~ m/(.{30})/; # will extract the first 30 characters, if the string is AT LEAST 30 characters long $string =~ m/.{30}/; # tests if the string is AT LEAST 30 characters long length($string) == 30; # tests if the string is 30 characters long.