Read file content to a scalar variable : file read « File « Perl
- Perl
- File
- file read
Read file content to a scalar variable
open (FILEHANDLE, "<file.txt") or die "Cannot open file.txt";
$text = "";
until (eof FILEHANDLE) {
read (FILEHANDLE, $newtext, 1)
$text .= $newtext;
}
print $text;
Related examples in the same category