in reply to Finally, C
Is there any way, in Perl, to create an alias to a lexical?Yes, but it requires a trick:
And there's the @_ trick you already mentioned. There are also a couple of constructs that allow you to alias a variable to $_.my $foo = "foo"; for my $bar ($foo) {$bar = "bar"} print $foo; __END__ bar
Lexicals seem very different to me from anything there's in C, am I wrong?Maybe, depending on what you are asking. If you mean that variables are implemented different than in C, yes, you are right. If you are referring to what differs a (Perl) lexical variable from a (Perl) package variable, and want to know how this differs from the C equivalent, then there's no real answer. In C, all variables are lexical - there's no such thing as name spaces in C.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finally, C
by QM (Parson) on Dec 16, 2005 at 23:56 UTC |