Maybe now is a good time to learn about Perl? See perlsyn for a basic overview of the syntax.
$res->header('Location') is a call to the
header method of whatever class
$res is in. It passes one parameter with the value
Location.
While Perl has sigils and often these can be used in interesting ways, there are some restrictions on their use as you can't make things up and expect Perl to infer what you mean. Putting a @ before a reference, as in @$res tells Perl that you want to treat $res as an array. But, as Perl certainly has told you when you tried to run your code, $res does not behave like an array reference and hence Perl refused to do what you told it.