use strict; use diagnostics; use warnings; # Define label variable my $build = $ARGV[0]; die "\nScript aborted. Study code is missing as an argument.\n\nUsage: $0 {STUDYCODE}\n" if @ARGV == 0; open (LABELS, 'labels.txt') || die "Can't open labels.txt \n$!\n"; while () { my $data_line = $_; # if ($data_line =~ /$build/) { # Remove lines beginning with "bl", "BL" or "_" and releases with a label with xx.yy.zzz.nnn(n) $data_line =~ s/^[BbLl].*|^_.*|^.*\d\d\d\.\d\d\d.*//g; #chomp ($data_line); #Remove end of lines #$data_line =~ tr/\n//s; # Still have blank lines I need to remove print "$data_line"; } } close LABELS; exit; #### _STUDYABCD1234_1.00 _STUDYABCD1234_1.00.5678 STUDYABCD1234_1.00 STUDYABCD1234_1.00.000 p_STUDYABCD1234_1.00.000 p_STUDYABCD1234_1.00.000.5678 bl_STUDYABCD1234_1.00.000 bl_STUDYABCD1234_1.00.000.5678 BL_STUDYABCD1234_1.00.000 BL_STUDYABCD1234_1.00.000.5678