Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
"be consistent"
 
PerlMonks  

Re: Find Element of array but use the next Element

by packetstormer (Monk)
on Jun 15, 2012 at 07:42 UTC ( #976380=note: print w/ replies, xml ) Need Help??


in reply to Find Element of array but use the next Element

If you are using 5.12 you can use this:

#!/usr/bin/perl use strict; use warnings; my @arr = ('app', 'Oracle', 'EPDMCA', 'Oracle' ,'EPZXC'); while (my($index,$value) = each @arr ) { if($value eq "Oracle") { print "Value next to Oracle is:$arr[$index+1]\n" } }


Comment on Re: Find Element of array but use the next Element
Download Code
Re^2: Find Element of array but use the next Element
by afoken (Parson) on Jun 15, 2012 at 20:43 UTC

    ... with the little problem that it does not like Oracle as last Element of @arr:

    my @arr = ('app', 'Oracle', 'EPDMCA', 'Oracle' ,'EPZXC','Oracle');
    Value next to Oracle is:EPDMCA Value next to Oracle is:EPZXC Use of uninitialized value within @arr in concatenation (.) or string +at 976380.pl line 11. Value next to Oracle is:

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-04-18 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (469 votes), past polls