Hello all. I have a problem which seems to make no sense to me.
Therefore I must be doing something wrong.
I am trying to populate an array using split with a regexe.
Here is the code (snippet only).
[code=perl]
my $date = $q->param('date' ); # 20090112 format
@dateArray = split(/(\d{4})(\d{2})( \d{2})/, $date);
[/code]
After this I loop through the array using print and all the values show up.
BUT if I try to access a particular indice nothing shows up. ???
example:
[code=perl]
# After above code
for(@dateArray) {
print $_, "\n";
}
# This works printing 2009 \n 01 \n 12 \n
# BUT....
print $dateArray[0]; # OR...
print "$dateArray[0]";
# Prints nothing to the screen.
[/code]
What am I doing wrong?
I really need the three individual values, NOT the whole array.
Is there a better what to accomplish this without split?
I just need to pass a number, and be able to use the parts separately.
thanks in advance!
Therefore I must be doing something wrong.
I am trying to populate an array using split with a regexe.
Here is the code (snippet only).
[code=perl]
my $date = $q->param('date' ); # 20090112 format
@dateArray = split(/(\d{4})(\d{2})( \d{2})/, $date);
[/code]
After this I loop through the array using print and all the values show up.
BUT if I try to access a particular indice nothing shows up. ???
example:
[code=perl]
# After above code
for(@dateArray) {
print $_, "\n";
}
# This works printing 2009 \n 01 \n 12 \n
# BUT....
print $dateArray[0]; # OR...
print "$dateArray[0]";
# Prints nothing to the screen.
[/code]
What am I doing wrong?
I really need the three individual values, NOT the whole array.
Is there a better what to accomplish this without split?
I just need to pass a number, and be able to use the parts separately.
thanks in advance!
Comment