Re: What's up with the double dollar sign? ($$)
From: Chris Hope (chris_at_electrictoolbox.com)
Date: 04/27/04
- Next message: Nechama: "Re: What's up with the double dollar sign? ($$)"
- Previous message: Niall Kavanagh: "Re: overwrite to file"
- In reply to: ScareCrowe: "What's up with the double dollar sign? ($$)"
- Next in thread: Markus Ernst: "Re: What's up with the double dollar sign? ($$)"
- Reply: Markus Ernst: "Re: What's up with the double dollar sign? ($$)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 28 Apr 2004 08:15:34 +1200
ScareCrowe wrote:
> I think it has something to do with globals, but what exactly is the
> purpose of the '$$' with variables?
> I mean what's the difference between '$var' and '$$var'?
> When would be the appropriate time to use '$$' instead of '$'?
$foo = 'bar';
$bar = 'xyz';
$zoo = 'abc';
print $foo . "\n";
print $bar . "\n";
print $$foo . "\n";
This will print out
bar
xyz
xyz
$$foo is evaluated as $bar because the value of $foo is 'bar'. If $foo was
changed to $foo = 'zoo' then print $$foo would now print 'abc'
The purpose of doing so? I find it often obfuscates code but I'm sure there
must be some useful purpose for it sometimes.
Hope this all makes sense...
-- Chris Hope The Electric Toolbox - http://www.electrictoolbox.com/
- Next message: Nechama: "Re: What's up with the double dollar sign? ($$)"
- Previous message: Niall Kavanagh: "Re: overwrite to file"
- In reply to: ScareCrowe: "What's up with the double dollar sign? ($$)"
- Next in thread: Markus Ernst: "Re: What's up with the double dollar sign? ($$)"
- Reply: Markus Ernst: "Re: What's up with the double dollar sign? ($$)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|