my $inLine = "RPC, rpc #001b, (1987)"; my $year; if ($inLine =~ /\((\d+)\)/) { $year = $1; } else { die "No year found in '$inLine'.\n"; } print "Found year '$year' in '$inLine'.\n"; #### my $inLine = "RPC, rpc #001b, 1987"; $inLine =~ /(#\d+[a-z])/; my $rpcNum = $1; print "Found rpc num '$rpcNum' in '$inLine'.\n"; $inLine =~ /\((\d+)\)/; my $year = $1; print "Found year '$year' in '$inLine'.\n"; #### Found rpc num #001b in RPC, rpc #001b, 1987. Found year #001b in RPC, rpc #001b, 1987.