my ($error) = $line =~ /.*](.*)/; #### my $error = substr($line, rindex($line, ']') + 1);