in reply to Regular expression
If it is fixed length, unpack is where you have to look first. If the record has delimited fields (of possibly varying lengths), split or a regular expression is more likely to help you.
A tentative solution for delimited fields is:
Which gives: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";
First: rs5443 Second: 61902 Third: 291008
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|