Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: match two elements from an array in a row

by graff (Chancellor)
on Aug 17, 2007 at 03:02 UTC ( #633210=note: print w/replies, xml ) Need Help??


in reply to match two elements from an array in a row

my @data = qw( 01 b2 01 00 b6 81 81 01 b4 0a 01 01 01 01 00 01 00 00 01 00 c7 82 82 01 b2 01 00 b8 ); for ( 1 .. $#data ) { if ( $data[$_] =~ /(8[12])/ and $data[$_] eq $data[$_-1] ) { print "Match $1 ending at index $_\n"; } }
(update: rearranged my conditions as perl Kanji's premature optimization. :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-01-24 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?