in reply to Re: Problem with "use constant" and UDP socket connection
in thread Problem with "use constant" and UDP socket connection

I haven't tried your shift(@ARGV) suggestion out, but in my application I can have multiple options -- one of them being to specify a server. (So in the real code, it's more than simply "shift @ARGV").

As others are very quick to point out that constants are for constants, using "use constant REMOTE_HOST" is not my choice. It's necessary because Socket wants its information that way. What seems unnecessary is not being able to specify a server name through a variable.

I feared "use Socket" would immediately pull it in, but thought I read somewhere I could do an 'if' around it. Guess not.

With your example "use constant REMOTE_HOST => shift(@ARGV)", this works at compile time because @ARGV is known at compile time?

  • Comment on Re^2: Problem with "use constant" and UDP socket connection

Replies are listed 'Best First'.
Re^3: Problem with "use constant" and UDP socket connection
by TedYoung (Deacon) on Oct 21, 2005 at 13:14 UTC

    I might be out in left field here but I don't see any requirement that their various functions you are using requires constants. gethostbyname and socket can accept variables. AMAF, there is very, very little difference in passing and variable vs. a constant to a sub.

    use vars; :-)

    Ted Young

    ($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)