NAME
Tie::ScalarFile -
SYNOPSIS
use Tie::ScalarFile;
my $string;
tie ($string, "Tie::ScalarFile", "file.txt");
$string = <<".EOF.";
blah blah blah...
.EOF.
#file.txt now contains "blah blah blah...".
print $string; #prints "blah blah blah...".
print count; #prints "1".
DESCRIPTION
Tie::ScalarFile is a perl module for associating scalars with files. You can then add to the scalar, and the file will be written to. You can read the value, and the file will be read from.
FUNCTIONS
- count
-
counts the number of currently tied scalars, and returns it. for example:
tie (my $string, "Tie::ScalarFile", "file.txt"); tie (my $string2, "Tie::ScalarFile", "file2.txt"); print count; #prints "2".
EXAMPLE
here is a real-life example:
#!/usr/local/bin/perl -w
use Tie::ScalarFile;
my $contents;
tie ($contents, "Tie::ScalarFile", "test.txt");
while (<>) { #while there's stdin...
$contents = $_; #...write the input to the test.txt file...
print $contents; #...and then read it in and print it.
}
print "There are " . count . "tied scalars."; #print the number of tied scalars.
EXPORT
count
SEE ALSO
AUTHOR
Linc Nightcat, <nightcat@crocker.com>
COPYRIGHT AND LICENSE
Copyright (C) 2005 by <nightcat>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 100:
You forgot a '=back' before '=head1'