Home > Archive > PERL Beginners > May 2006 > Converting a string to a filehandle
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Converting a string to a filehandle
|
|
| Wijaya Edward 2006-05-21, 9:58 pm |
|
Dear expert,
Is there a way to do it? Module for it? Suppose I have this large string.
my $string = 'foo bar
qux woo
etc etc';
I would like to convert that string as if it is stored inside a file, and bypassing the file creation step.
For example,
my $filehandle = do_sth_to_convert($string);
Such that I can straight away do things like:
while (<$file_handle> ) {
print;
}
[download]
Regards,
Edward WIJAYA
SINGAPORE
------------ Institute For Infocomm Research - Disclaimer -------------
This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its contents to any other person. Thank you.
--------------------------------------------------------
| |
| Charles K. Clarkson 2006-05-21, 9:58 pm |
| Wijaya Edward wrote:
: I would like to convert that string as if it is stored
: inside a file, and bypassing the file creation step.
I think you want the IO::Scalar module.
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer
254 968-8328
Don't tread on my bandwidth. Trim your posts.
| |
| Xavier Noria 2006-05-22, 3:59 am |
| On May 22, 2006, at 4:44, Wijaya Edward wrote:
> Is there a way to do it? Module for it? Suppose I have this large
> string.
>
>
> my $string = 'foo bar
> qux woo
> etc etc';
>
>
>
> I would like to convert that string as if it is stored inside a
> file, and bypassing the file creation step.
> For example,
>
> my $filehandle = do_sth_to_convert($string);
Yes, since 5.8.0 that's built-in:
open my $filehandle, '<', \$string;
-- fxn
|
|
|
|
|