Yes, but can this be simplified?
For example, I can store all the boxes that exist in an array as: $box(i)="L:M:N". Now I can store cooridinates as:
$x[l][m][n][i]=Xvalue of i'th atom in the box
$y[l][m][n][i]=Yvalue of i'th atom in the box
$z[l][m][n][i]=Zvalue of i'th atom in the box
Then all I would need to do is to loop over all boxes (using @box) and checking existence of it's neighbouring boxes (I would need a hash here, I guess... Emmm..., box should be a hash and I can use its values in the above), and for all those exists I can loop over their atoms.
Does this make sense or sound better?