I'm not sure what you're trying to accomplish here, nor why you think it would be a common thing to do. Anyway, the reason it doesn't work is the reason why you shouldn't normally use for for reading from files (especially large ones), it slurps the whole file into a list in memory first before processing it. So by the time you try to assign to $x you're already at the end of the file and naturally can't read any further. Try using while instead of for.
In reply to Re: nested <FILE> read returns undefined?
by tirwhan
in thread nested <FILE> read returns undefined?
by argv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |