in reply to Reading parts of array elements

Sometimes I wonder if we could do something like $foo[0][0], $foo[1][0], etc, things might become easier.
I always do my $first_char = (split ('', $foo[0]))[0]; when I met similar problems.

Replies are listed 'Best First'.
Re^2: Reading parts of array elements
by GrandFather (Saint) on Dec 09, 2009 at 07:52 UTC
    my $first_char = substr $foo[0], 0, 1;

    is much clearer, at least to my eye, probably executes faster and is faster to type too. What you might call a 'win win win' scenario.


    True laziness is hard work

      Thanks for this, I have to say that this is much better than my way of doing it.
      Mine's more or less a bad example. :)