in reply to Re^2: What is the difference between $array[1] and @array[1]?
in thread What is the difference between $array[1] and @array[1]?
Does that mean you disagree with the warning?
It's meant to enforce style, but I agree with the style being enforced, and it can detect typos (refactoros?).
Or are you like the ancient Greek who didn't consider 1 not to be a proper number, and you don't consider one-element lists to be proper lists?
Do you honestly think in terms of lists when you do $a[4]? I don't.
But sometimes, the slice one wants is just one element.
Of course. I didn't mean to imply otherwise. Note that Perl doesn't warn when you don't use a constant.
$ perl -wle'my @a = qw( a b c ); my @i = 2; print @a[@i]' c
In fact, using $ wouldn't work in that situation.
$ perl -wle'my @a = qw( a b c ); my @i = 2; print $a[@i]' b
I can't figure out what you think I was saying, but hopefully this clears it up.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: What is the difference between $array[1] and @array[1]?
by JavaFan (Canon) on Apr 07, 2009 at 16:52 UTC | |
by ikegami (Patriarch) on Apr 07, 2009 at 17:09 UTC | |
by JavaFan (Canon) on Apr 07, 2009 at 21:21 UTC | |
by ikegami (Patriarch) on Apr 07, 2009 at 22:30 UTC | |
by Porculus (Hermit) on Apr 07, 2009 at 20:05 UTC | |
by JavaFan (Canon) on Apr 07, 2009 at 21:26 UTC |