in reply to Re^2: URL Redirect
in thread URL Redirect

I am still confused as to what
my ( $NewUrl ) = $res->header('Location');
exactly is.

What exactly is "$res->header('Location')"? Is it a reference pointing to an array inside LWP?

If I wanted to see the whole potato, why does
my @Headres = @$res->header('Location')
not work?

How would I assign the whole potato to @Headers?

I am confused.

Many thanks,
-T

Replies are listed 'Best First'.
Re^4: URL Redirect
by Corion (Patriarch) on Sep 07, 2016 at 06:52 UTC

    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.