in reply to Using eval to build array structure
Please switch to a 2-dimensional array. See References Quick Reference for the very short story on how to dereference complex data structure references in Perl.
- tye (but my friends call me "Tye")#!/usr/bin/perl -w use strict; my ($i, $j); my @a= ( [1,2,3,4,5], [2,1,3,5,4], [3,4,5,1,2], [4,2,3,5,1], [5,4,3,2,1], ); for $i(1..4){ for $j($i+1..5){ if ($a[$i][0] == $a[$j][0]){ print "Matched one!\n"; unshift @{$a[$i]}, pop @{$a[$j]}; push @{$a[$j]}, pop @{$a[$i]}; last; } } }
|
|---|