$1 and $2 are quite volatile variables, in the sense that they only start being defined after a regex with matching groups, and that they'll have a different value after the next one. Better save it to a new variable as soon as possible after the regex.
Aside from that, this is always a good idea at the beginning of your script:
#!/usr/bin/perl -W
use strict;
use warnings;
This will enable strict variable declaration (using my or our) and a few warnings that might turn into bugs down the road.
Global symbol "$content" requires explicit package name at test2.pl line 10.
Global symbol "$content" requires explicit package name at test2.pl line 11.
Global symbol "$plain_text" requires explicit package name at test2.pl line 13.
Global symbol "$content" requires explicit package name at test2.pl line 13.
Global symbol "$mystringa" requires explicit package name at test2.pl line 16.
Global symbol "$plain_text" requires explicit package name at test2.pl line 16.
Global symbol "$mystringa" requires explicit package name at test2.pl line 17.
Global symbol "$mystringb" requires explicit package name at test2.pl line 23.
Global symbol "$plain_text" requires explicit package name at test2.pl line 23.
Global symbol "$mystringb" requires explicit package name at test2.pl line 24.
Global symbol "$plain_text" requires explicit package name at test2.pl line 34.
Not sure how to fix it ?
Could you please post some example of re saving variables
use strict;
my $var1 = "Test 1"; #Good
$var2 = "Test 2"; #This will fail
Example 2: saving variables
use strict;
my $string = "This is a test";
$string =~ m/ (..) /g;
my $save = $1;
print $save, "\n"; # Prints "is", followed by a newline
Also, there's a lot of documentation on perldoc.perl.org, including some where fine tutorials. All documentation there can also be found on your local system using the "perldoc" command.