I just wrote such code. This can help. It basically looks like yours, except for mine it has a few brackets.
my $path = `ls -l -d ~/`;
($user) = ($path=~/\.*\s+(\w+)\susers/);
So yours from this example might be something like this if you are trying to save all this? I'm not sure, but you can use mine as an example. I store everything that is in (\ w +):
($link) = ($html_data =~ (m/<iframe id="pdfDocument" src=.(.*)pdf/g));
source
share