in reply to perlish way of splitting file records

you can also use an anonymous array to accomplish what you attempted in your second example:
print [ split(/:/,<FILEHANDLE>) ]->[3]
Oddly enough, to use a list slice there are some subtle parenthesis issues:
# this works: print ((split /:/, <FILEHANDLE>)[3]); # doesn't work (note the missing outer parenthesis): print (split /:/, <FILEHANDLE>)[3];
I'm guessing the second example has some ambiguity with taking the slice off the print or the split
-- Brian

Update: As pointed out below, an anonymous array is slower (by 39%) than a plain ol' list slice. Depending on the circumstances, however, it's very unlikely that this slowdown would ever be noticable (since on the box I tested, it was still able to perform 89,445 anonymous array creations and access per second).

Replies are listed 'Best First'.
Re^2: perlish way of splitting file records
by VSarkiss (Monsignor) on Jun 01, 2006 at 16:39 UTC
Re^2: perlish way of splitting file records
by ikegami (Patriarch) on Jun 01, 2006 at 17:25 UTC
    Yes, it's possible to use an anonymous array, but it's needlessly expensive when a list slice will do.