Q:

Print a substring of an array value

I have an array in the third element dataArr[2], I know it contains a 10 digit phone.  I need to only read or print the first 6 digits. For instance if my phone is 8329001111, I need to print out the 832900.  I tried to see if I can use substr but I keep reading or printing the full list. Do I need to dereference..

A:

Try this :
$dataArr[2] =~ s/\s//g; # ensure there's no spaces

print substr($dataArr[2], 0, 6);
#               ^         ^  ^
#            variable     |  |
#             offset start|
#                            |
#                          substring length

