in reply to Can Perl Turn A String Into A Virtual File?
Then, if you want to use a file, you can dowhile(@lines) { ... }
or for a string@lines = <MYFILE>;
prior to executing the loop. Setting up a string to work via a file handle is a little extreme, unless you need it to work in both cases and the files you are working with are too large to be worth reading in in a single gulp. This is one of the things the IO::String is supposed to do, and the thing you would need to do to use the form you originally proposed. But IO::String, according to its documentation, does not yet have this feature implemented! So, unless have huge files, just go with the the way of the array.@lines = split /\n/, $string;
|
|---|