KBD

Keith Devens .com

Friday, July 30, 2010 Flag waving
Everybody makes their own fun. If you don't make it yourself, it ain't fun -- it's entertainment. – David Mamet (as relayed by Joss Whedon)
← Switching spam filtersUnicode design flaws? →

Daily link icon Saturday, August 23, 2003

Pretend a string is a file in Perl

Cool, there's a way to treat a string like a filehandle (but only in Perl 5.8).

← Switching spam filtersUnicode design flaws? →

Comments XML gif

Sam Kington (http://www.illuminated.co.uk/blog/) wrote:

Alternatively, for other versions of Perl, use IO::Scalar.

∴ Sam Kington | 23-Aug-2003 6:50am est | http://www.illuminated.co.uk/blog/ | #2777

Keith (http://www.keithdevens.com/) wrote:

Man, I need to be better acquainted with Perl's standard library and CPAN. Thanks.

Keith | 23-Aug-2003 10:37am est | http://www.keithdevens.com/ | #2780

Harry Fuecks (http://www.phppatterns.com) wrote:

If you ever try the same thing in PHP, you might be interested in stream_wrapper_register

∴ Harry Fuecks | 23-Aug-2003 6:48pm est | http://www.phppatterns.com | #2782

Keith (http://www.keithdevens.com/) wrote:

Man, that's awesome. I had no clue that existed either.

Keith | 23-Aug-2003 8:40pm est | http://www.keithdevens.com/ | #2783

Mark (http://diveintomark.org/) wrote:

In Python, use the StringIO module (or cStringIO if available):

from StringIO import StringIO
stream = StringIO('foo')
print stream.read() # or whatever

∴ Mark | 23-Aug-2003 11:30pm est | http://diveintomark.org/ | #2784

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

July 2010
SunMonTueWedThuFriSat
 123
45678910
11121314151617
18192021222324
25262728293031



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

DTerm: A command line anywhere and everywhere

They wrote back. It turns out that,​when I launched it a second time, I​was...

Revence: Jul 26, 2:28am

Minimum Wage Increase Leads to Higher Teen Unemployment Rate - WSJ.com

Sorry, I don't believe it.  My son​was working as a dishwasher, making​$10/...

Bryan Price: Jul 25, 2:50pm

Generated in about 0.155s.

(Used 8 db queries)