in reply to perl extract a specific # from string

There are many ways to do this, it is not difficult, and it is all explained in perlretut. I would propose to just pick the non-whitespace characters at the end of the string:

$temp =~ /(\S+)$/;