Front page | perl.beginners |
Postings from July 2003
Why use symbolic refs?
Thread Next
From:
Kipp, James
Date:
July 31, 2003 11:26
Subject:
Why use symbolic refs?
Message ID:
EC6C49DE5C846143AA2CE580420E77C302B69DFD@xexwlm05.mbnainternational.com
In the "Advanced Perl book" it gives an example of using sym ref:
--
process a command-line option such as "-Ddebug_level=3" and set the
$debug_level variable. This is one way of doing it:
while ($arg = shift @ARGV){
if ($arg =~ /-D(\w+)=(\w+)/) {
$var_name = $1; $value = $2;
$$var_name = $value; # Or more compactly, $$1 = $2;
}
}
----
how is this any better than:
while ($arg = shift @ARGV){
if ($arg =~ /-D(\w+)=(\w+)/) {
$level = $2;
}
}
---
Or am i missing the point? I never use sym refs and just wondering why i
would ever want to
Thanks
Jim
Thread Next
-
Why use symbolic refs?
by Kipp, James