in reply to Deleting everything before a string
In the first case, how about
There's no need to do a substitution since you already know what you want the value of $content to be. Moreover, you probably have a default value in mind if the file fails to contain the match string, in which case you could use the ternary operator to do it:($file_text =~ /$string_to_match/) && $content = $string_to_match;
Finally, if you know the file contains the text, and that's what you want in the $content variable, just do a simple assignment.$content = ($file_text =~ /$string_to_match/) ? $string_to_match : $default_failure_value;
Update:
In case it's not obvious, I construed the question to
imply that the matching string was known beforehand,
rather than the delimiters. If the delimiters
are what is known beforehand, my advice is, well,
pointless.
|
|---|