use strict; my $line = 'Experiment: rs5443-61902_923_922_921_291008 Active filters: FAM (483-533), VIC /HEX / Yellow555 (523-568)'; my ( undef, $first, $second, undef, undef, undef, $third, undef ) = split /[- _]/, $line; print "First: $first\nSecond: $second\nThird: $third\n";