use strict; use warnings; my $inLine = 'RPC, rpc #001b, (1987)'; $inLine =~ s/\((\d+)\)$//; my $working = $1; print $working;