One of your mistakes is that you first create
$X which looks like it's a reference to array, but then try to print
@X[1], which is an element of
@X which is different to
$X. See this example:
$ perl -d -e 1
DB<1> $X = [ 1 .. 10 ]; # create a reference to an anonymous array
DB<2> x $X # print the array by its reference
0 ARRAY(0x9a45510)
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
DB<3> @X = ( 2 .. 20 ); # create an array
DB<4> x @X # display the array
0 2
1 3
2 4
3 5
4 6
5 7
6 8
7 9
8 10
9 11
10 12
11 13
12 14
13 15
14 16
15 17
16 18
17 19
18 20
DB<5> x @X[1] # display an element of the array
0 3
DB<6> x $X->[1] # display an element of the anonymous array by its r
+eference
0 2
See
perlreftut for more information.
Sorry if my advice was wrong.