I wanted to extract (using perl) xxx (string after Block:) and prod (string after Milestone:). The string (after Block: and Milestone:) and number of empty spaces are not standard. I only able to grep the full line using bottom command:
use strict;
use warnings;
my $file = 'xxx.txt';
open my $fh, '<', $file or die "Could not open '$file' $!\n";
while (my $line = <$fh>){
chomp $line;
# my @stage_status = $line =~ /(\:.*)\s*$/;
my @stage_status = $line =~ /\b(Block)(\W+)(\w+)/;
foreach my $stage_statuss (@stage_status){
print "$stage_statuss\n";
}
}
Example of line in a file:
| Block: | xxx | Milestone: | prod |