in reply to Re: Re: Re: Behavior of compile-time constants?
in thread Behavior of compile-time constants?

No, all you need to know is how => works. You have the same problem in:
#!/usr/bin/perl use strict; use warnings 'all'; sub foo { my %hash = (shift => 1); print keys %hash, "\n"; } foo "bar"; __END__
That prints shift and not bar.

Abigail

Replies are listed 'Best First'.
Re: Re: Behavior of compile-time constants?
by perrin (Chancellor) on Jun 14, 2002 at 18:24 UTC
    My recommendation to him was to use variables for his constants. (Yes, I know that sentence sounds bizarre.) Variables certainly behave differently in different contexts, but people are not as likely to make mistakes with them because they know they've got a variable rather than some mysterious constant thing.
      Let's go crazy and use the worst of both worlds:
      #!/usr/bin/perl use strict; use warnings 'all'; use variable i => 0; use variable array => []; array = [2, 4, 5, 8]; for (i = 0; i < 4; i ++) { print array -> [i], "\n"; } __END__ 2 4 5 8

      Abigail