Forum Moderators: coopster & phranque

Message Too Old, No Replies

Simple perl module that refuse to work

         

haryanto

12:10 am on Mar 22, 2004 (gmt 0)

10+ Year Member



Hi guys. I have written a perl module which doesn't seem to work.
I am just trying to change the contents of the file /home/mysite/testing . There is no extension to this file.
Only the 'print "Theme changed";' worked.

BUT............when I changed the permission of the file to 777 it works!

Can you guys help me figure out what is wrong?

Here goes the perl module:

#!/usr/bin/perl

package Mymodule::SetTheme;

use strict;

use vars qw(@ISA @EXPORT $VERSION);

require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(SetTheme_settheme);

$VERSION = '1.0';

require 5.004;

sub SetTheme_init {
return(1);
}

sub SetTheme_settheme {
open(HOMEDIRL,">/home/mysite/testing");
print HOMEDIRL "theme2";
close(HOMEDIRL);
print "Theme changed";
}

flashfan

4:44 am on Mar 22, 2004 (gmt 0)

10+ Year Member



It's permission issue. You want to write a file on your server, the write permission should be granted.

-F.

timster

6:12 pm on Mar 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's a good habit always to test whether opening a filehandle works, like so:

open(HOMEDIRL,">/home/mysite/testing") or die "Can't open file for writing. Reason: $!\n";

(Replace "die" with "warn" if you want the script to keep running.)