SPUG: Reading records from a filehandle or a scalar
Colin Meyer
cmeyer at helvella.org
Thu Apr 26 16:49:01 CDT 2001
Joe,
On Thu, Apr 26, 2001 at 10:22:23AM -0700, Joe Slagel wrote:
> Does anyone know of a cute trick to be able to read records
> from either a filehandle or a scalar. I guess you would
> need to treat the scalar as a file handle in order to get
> this to work.
Try IO::Scalar:
#!/usr/local/bin/perl
use IO::Scalar;
my $a=<<'eof';
line one
2nd line
larry says perl6 will use .'s to designate method calls:
$obj.meth(arg1); # a different char will mean concatenate
eof
tie *FILE, 'IO::Scalar', \$a;
while (<FILE>) {
print;
$count++;
}
print "\n\n$count lines\n";
-C.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list