in reply to Alternatives for index() ... substr() ?
It appears that the strings you want are separated by whitespace, have no whitespace embedded and $text is in a consistent format. If this holds true, I would split $text on whitespace, then extract the strings you want from the array.
if ($text =~ /FATAL: Error ... /){ my @parts = split /\s+/, $text; my $dt = "$parts[0] $parts[1]"; my $msg = $parts[6]; my $source = $parts[8]; my $destination = $parts[10]; ... }
|
---|