Actually the documentation says it returns ($content_type, $document_length, $modified_time, $expires, $server) so I'd write:
my ($content_type, $document_length, $modified_time, $expires, $server +) = head($url);
If you want that as a hash instead (Perl for "associative array") you could:
my %head; @head{qw(content_type document_length modified_time expires server)} = + head($url); die "Unable to get page '$url'\n" if !defined $head{content};
which uses a hash slice to initialize the key/value pairs. Note the % sigil which tells the viewer that head returns a hash. Access the fields like:
my $modified_time = $head{modified_time};
Now see that we use a $ sigil to show that head{modified_time} returns a scalar value. The sigil ($, @, % or &) tells you what type of thing the expression returns. See perldata for extensive documentation on Perl's data structures and variable naming etc.
In reply to Re: question about variables from new perl user
by GrandFather
in thread question about variables from new perl user
by rst
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |