UseModWiki | RecentChanges | Preferences

UseModWiki/Documentation: Functions: ReadFile

Given : a filename as input, return a pair.

Returns: a pair

        The first element of the pair is 0 or 1 (fail or success)
        The second element of the pair is the complete file named by the input argument.

Global Variables:


Q I don't see a test to see if the file exists already.

A It's why there's the if.

 sub ReadFile {
   my ($fileName) = @_;
   my ($data);
   local $/ = undef;   # Read complete files

   if (open(IN, "<$fileName")) {
     close IN;
     return (1, $data);
   return (0, "");

UseModWiki | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited February 14, 2008 4:00 pm by MarkusLude (diff)