Let's say I have the source code to a webpage contained as a string in a scalar, and all I want to do is print JUST the <body> tag (and everything contained within). I did it like this:
$source =~ s/(<body[^>]+>)/$1/;
print $1;
This works fine - but is there a more appropriate way to do it? It just somehow seems that the substitution function isn't designed for this, but I don't know a better way.
$source =~ s/(<body[^>]+>)/$1/;
print $1;
This works fine - but is there a more appropriate way to do it? It just somehow seems that the substitution function isn't designed for this, but I don't know a better way.