Perl regex

Hello folks,

Looking for a quick help on regex in my perl script.

here's the string i want to parse and get the 2nd field out of it.

$str = "        2013-08-07 12:29        Beta            ACTIVE";

I want to extract 'Beta' out of this string. This string will keep on changing but the format will be same as above. The second field i'm interested in might be a combination of alphanumeric and non-whitespace character like '_'

e.g.

$str = "        2013-08-07 12:29        Backup_Beta_08072013        ACTIVE";

I want the 'Backup_Beta_08072013' to be extracted from above line.
Please help.

If the format is the same, this should work:

my $str1 = "        2013-08-07 12:29        Beta            ACTIVE";
my $str2 = "        2013-08-07 12:29        Backup_Beta_08072013        ACTIVE";

my @newstr1 = split(/ {4}/, $str1);
my @newstr2 = split(/ {4}/, $str2);

print "$newstr1[4]\n";
print "$newstr2[4]\n";

./getSTR.pl
Beta
Backup_Beta_08072013

The regex

^.*\s+(\S*Beta\S*)\s+

matches both:

$cat dat
        2013-08-07 12:29        Beta            ACTIVE
        2013-08-07 12:29        Backup_Beta_08072013        ACTIVE
$                                                                  
$perl -n -w -e 'm|^.*\s+(\S*Beta\S*)\s+| ; print "$1" ."\n"; ' dat 
Beta
Backup_Beta_08072013
$