Accessing elements in array ref of array references

Discussion in 'Perl Misc' started by fatted, Jul 11, 2003.

  1. fatted

    fatted Guest

    Currently I'm comparing the first value of each of the array
    references (which are stored in an array reference $ref_ref) as
    follows:

    if(map($_->[0] =~ /$keyword/i,@$ref_ref))
    {
    # Do something cunningly clever...
    }

    What I was wondering about (for no particular reason) is doing
    something like:

    if(map(/$keyword/i,cool_function(@$ref_ref, 0)))
    {
    # Do something equally cunningly clever...
    }

    Any idea's? (or should I get back to work ;)
    fatted, Jul 11, 2003
    #1
    1. Advertising

  2. fatted

    Fatted Guest

    "Greg Bacon" <> wrote in message
    news:...
    > In article <>,
    > fatted <> wrote:
    >
    > : [...]
    > :
    > : What I was wondering about (for no particular reason) is doing
    > : something like:
    > :
    > : if(map(/$keyword/i,cool_function(@$ref_ref, 0)))
    > : {
    > : # Do something equally cunningly clever...
    > : }
    > :
    > : Any idea's? (or should I get back to work ;)
    >
    > If I understand you, cool_function would be equivalent to
    >
    > sub cool_function {
    > my $i = pop;
    > map $_->[$i], @_;
    > }
    >
    > We're discussing things at such a low level that we may be obscuring
    > an XY problem. What are you trying to do?


    What I was interested in was keeping the map structure as I would normally
    use it for mapping over a "normal" array and matching against $_ (eg
    map(/$keyword/i,...), but mapping over the 0th element in each of the array
    references which are stored in the array reference. Basically form an array,
    which contains all the 0th elements of the array references, and then map
    over it. If that makes sense :) I've no particular need to for this, but
    just curiosity to see if I could form the map statement slightly
    differently. (I think I'm forming an unhealthy fascination with map :)
    Fatted, Jul 24, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    331
  2. Replies:
    22
    Views:
    740
    peter koch
    Apr 30, 2008
  3. Replies:
    6
    Views:
    333
    James Kanze
    Apr 29, 2008
  4. Navindra Umanee

    strong ref from weak ref?

    Navindra Umanee, Feb 12, 2005, in forum: Ruby
    Replies:
    2
    Views:
    136
    Navindra Umanee
    Feb 12, 2005
  5. Juha Nieminen
    Replies:
    13
    Views:
    600
    Edek Pienkowski
    Aug 29, 2012
Loading...

Share This Page