Hello I am trying to truncate text between two hash keys and get all the strings in between those two strings. I have a function that can parse between two strings but when I try to parse between two strings that contain the '=>' characters I get an uninitialized variable error. Thank you monks for your endless wisdom :)
#Function call That works my $hashData = truncateText($inputText, "begin", "end"); #Desired function call that doesn't work my $hashData = truncateText($inputText, "begin =>", "end =>"); #Truncating Function sub truncateText{ #Truncates text by removing everything before and and after the pa +ssed in variables my($text, $beginString, $endString) = @_; my $truncatedText; if($text =~ /\b\Q$beginString\E\b(.*?)\b\Q$endString\E\b/s){ $truncatedText = $1; } return $truncatedText; }
In reply to parsing to get data between '=>' characters by victorz22
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |