Stephen Patterson wrote, on Wednesday, February 13, 2002 2:00 PM : I have a scalar variable which I need to run read() on, but read() : runs only on a filehandle, and I'd like to avoid creating a temp file : just for this one operation. Is there any way I can use the variable : as if it were a filehandle?
Why? From the doc: read FILEHANDLE,SCALAR,LENGTH,OFFSET read FILEHANDLE,SCALAR,LENGTH Attempts to read LENGTH bytes of data into variable SCALAR from the specified FILEHANDLE. Returns the number of bytes actually read, "0" at end of file, or undef if there was an error. SCALAR will be grown or shrunk to the length actually read. If SCALAR needs growing, the new bytes will be zero bytes. An OFFSET may be specified to place the read data into some other place in SCALAR than the beginning. The call is actually implemented in terms of stdio's fread(3) call. To get a true read(2) system call, see "sysread". What part of that can't you use substr for? Or are you using sysread? SCALAR = substr $myscalar, OFFSET, LENGTH len(SCALAR) gets you the "bytes read" (0 for "end of myscalar"), and it even returns undef if you try to read completely outside $myscalar. Joe ============================================================== Joseph P. Discenza, Sr. Programmer/Analyst mailto:[EMAIL PROTECTED] Carleton Inc. http://www.carletoninc.com 219.243.6040 ext. 300 fax: 219.243.6060 Providing Financial Solutions and Compliance for over 30 Years _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs