From: gst <[EMAIL PROTECTED]>
> iirc, in C if I store somwhere a pointer to a "stack" value (e.g.:
> call a function with an auto variable, return its pointer) i know i'm
> going to mess things, since that piece of data will be most probably
> overwritten by subsequent calls.
>
> if I do the same in Perl (with a hard ref), do I have any guarantee
> that the same behavior (implicit aliasing) does - or does not (every
> new scalar is guaranteed to not alias the old non existant value) -
> apply?
There is no real stack in Perl as far as variables are concerned and
if there are any references left to a value, it will stay put and
will never be overwritten by new variables.
You can even do things like:
while (<>) {
my @items = split ',', $_;
my %row = (name => $items[0], email => $items[1], age =>
$items[2]);
push @people, \%row;
}
and it will work well ... each iteration will get a new hash and the
%people array will contain as many different hashes as there was
lines in the input.
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/