in reply to Re: What Are Your Live Journal Friends Interested In?
in thread What Are Your Live Journal Friends Interested In?
Thanks for the kind words.
The my trick is an old one that relies on a feature of my that is not documented in perldoc -f my (though my is so ubiquitous that I suspect many people have not even read that perldoc). You see, my, like most Perl functions, has a return value. It returns variable it's declaring. That allows you to do stuff like this:
chomp(my $data = <FH>); while ((my $foo = some_func()) eq 'bar') { ... }
You can also use it to assign values to more than one variable:
perl -MData::Dumper -e 'my @a = my ($x,$y,$z) = localtime;print Dumper \@a'In short, were it not for this feature, Perl would lose many nifty timesavers.
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re(2): What Is 'my' Interested In?
by theorbtwo (Prior) on Jan 30, 2004 at 17:49 UTC | |
by ysth (Canon) on Jan 30, 2004 at 18:43 UTC | |
|
Re: Re(2): What Is 'my' Interested In?
by benizi (Hermit) on Feb 02, 2004 at 20:24 UTC |