Page is a not externally linkable
- Code, Content, and Presentation
-- Perl Server Side CGI Scripting
---- Assign contents of file to a scalar variable


dkubb - 4:18 am on Feb 2, 2004 (gmt 0)


Here's my favorite way to "slurp" a file into a scalar:

open FILE, 'inputfile' or die "Could not open file inputfile: $!";
sysread(FILE, my $content, -s FILE);
close FILE or die "Could not close file: $!";


Thread source:: http://www.webmasterworld.com/perl/3446.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com