in your code:
- Your data are not linked to each others in any way
- Although you used 'my' to declare some of your variables at the very top of your script, Those are now global variables which is something you do not need to do in your case.
- Consider adding use strict; use warnings; at the top of your code
- split function returns an array you can access it's elements by supplying the ids counting from zero
my ($X,$Y,$Z) = (split/_/,$file)[2.3,4];
or if you don't like using those numbers consider using undef for the element you don't need rather than using a bogus variable $unwanted
<code>
my (undef,undef,$X,$Y,$Z) = split /_/,$file;
- in perl you should use 'eq' and/or 'ne' for strings comparison and I as I can see you are using numerical comparison when comparing the date to an empty string which is wrong
Hopes those comments will help you out.