...works in every instance except when trying to print it immediately.
You're probably running afoul of the function vs. "list operator" nature of builtin's when called with and without parentheses, respectively. Specifically, perl sees that first parenthesis and says to itself, "Oh! That must be a function call," when, really, you want those parentheses to create a list that you can then subscript. So you end up subscripting the return value of print (ie, a list containing a single element: (1)) Try:
print +(split(...))[3]; # force "list operator" mode, or...
print( (split(...))[3] ); # make the whole thing a function call.
Update: Elucidated exactly what I meant by "running afoul". :-)
bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are. |