in reply to Problem with Regex
I tried to do a function that takes the text and the tag as an input and returns the data of that tag, but it returns nothing.
sub My_Regex { my($raw_text, $tag) = @_; $raw_text =~ /<$tag>{1}(.*)(<\/$tag>){1}/; my $output = $1; print "OUTPUT: $output\n"; }
But it does return something, it returns the return value of the last statement in the sub which is print which returns true or false.
But anyway, you probebly want something like this:
sub My_Regex { my ( $raw_text, $tag ) = @_; return $raw_text =~ /<$tag>(.*?)<\/$tag>/s ? $1 : ''; }
|
|---|