Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Reading parts of array elements

by pid (Monk)
on Dec 09, 2009 at 07:39 UTC ( [id://811872]=note: print w/replies, xml ) Need Help??


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. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://811872]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-29 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found