# Test line $line = "------------------- Frame 1 ------"; # Parse it by changing all -, letters, and spaces into nothing $line =~ s/[\-|A-Z|a-z|\s+]//g; # Print the line which returns '1' or whatever number it might be print "$line\n";