in reply to string problem

You could also just use a match global to extract all 5 digit numbers that are preceded by a space.
#!/usr/bin/perl -w use strict; my $text = 'scaffold_12147 protein_coding exon 32192 32242 . - . gene_ +id "ENSTBEG00000007763'; my @numbers = ($text =~ /\s(\d{5})/g); print "@numbers\n"; #prints 32192 32242
Update: slight wrinkle:
#!/usr/bin/perl -w use strict; open FILE, "vik.txt" or die $!; while(<FILE>) { my ($exon, $number1, $number2) = (split /\s+/, $_)[2,3,4]; if (defined ($exon) and $exon eq "exon") { print "$number1 $number2\n"; } }