|
|
| Henrik Nielsen 2007-12-12, 7:02 pm |
| Hi
Whats with the \$t in this sub?
sub timestamp { my $t = localtime; \$t }
And what does this do?
sub timestamp { my $t = localtime; }
Henrik
| |
| Yitzle 2007-12-12, 7:02 pm |
| In perl, the last variable ____ in a function is returned.
sub timestamp { my $t = localtime; \$t }
is the same as
sub timestamp { my $t = localtime; return \$t; }
This function stores the localtime (seconds since epoch?) in a
variable $t, then returns a reference to $t.
| |
| Tom Phoenix 2007-12-12, 7:02 pm |
| On 12/12/07, Henrik Nielsen <quercus1974@gmail.com> wrote:
> Whats with the \$t in this sub?
> sub timestamp { my $t = localtime; \$t }
>
> And what does this do?
> sub timestamp { my $t = localtime; }
The localtime function is documented in the perlfunc manpage. It's
being used here in a scalar context. References are covered in the
perlreftut manpage, among others. Is that what you're looking for?
Cheers!
--Tom Phoenix
Stonehenge Perl Training
| |
| Gunnar Hjalmarsson 2007-12-12, 7:02 pm |
| yitzle wrote:
>
> sub timestamp { my $t = localtime; return \$t; }
> This function stores the localtime (seconds since epoch?) in a
> variable $t
No, seconds since epoch is not what localtime() returns and what's
stored in $t.
perldoc -f localtime
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
|
|
|
|