#!/usr/bin/perl use warnings; use strict; my $line = "BOGUS PPI3_SYNY3 276 aa linear BCT 13-NOV-2019\n"; if (my ($bogus, $acids) = $line =~ /BOGUS\s+([A-Z0-9_]+) ([0-9]+ [a-z]+)/) { print "bogus: $bogus\nNumber of acids: $acids\n" }