Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Manipulating Array Indexes

by Athanasius (Archbishop)
on Sep 07, 2020 at 16:30 UTC ( [id://11121448]=note: print w/replies, xml ) Need Help??


in reply to Manipulating Array Indexes

Hello TJ777, and welcome to the Monastery!

The PerlX::Window module by the Monastery’s own tobyink might provide you with another useful approach:

use strict; use warnings; use PerlX::Window; my @array = (1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1); while (defined window @array, 7) { if ($window[3] == 5) { print @window[4 .. 6], ', ', reverse(@window[0 .. 2]), "\n"; } }

Output:

2:27 >perl 2054_SoPW.pl 678, 432 432, 678 2:27 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found