in reply to Problem with "use constant" and UDP socket connection
use happens at compile time. So it gets executed before your variables are initialized in this case. On top of that, they are also being executed regardless of the conditional in the if statement (i.e. $udp_server is false). Any reason why you want to use constants here? Why not just use variables?
If you really wanted to use constant here you could do this:
use constant REMOTE_HOST => shift(@ARGV); my $udp_server = REMOTE_HOST;
One more note, the use Socket will be executed regardless of $udp_server (so it is always being "pulled in"). That could be changed to require Socket; import Socket if you didn't want it imported if $udp_server is false.
Ted Young
($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem with "use constant" and UDP socket connection
by shockers (Acolyte) on Oct 20, 2005 at 23:21 UTC | |
by TedYoung (Deacon) on Oct 21, 2005 at 13:14 UTC |