Saving files

Posted by Somec on Sat 03 Jan 2004 04:42 AM — 3 posts, 14,147 views.

#0
Here's my save function:


sub __save {
    my ($filename) = $_[0];
    
    unless(open(OUT, ">$filename")) {
        output("Cannot open $filename: $!");
        return;
    }
    
    print OUT $area_name . "\n";
    foreach (@area) {
        print OUT &__room_save($_) . "\n";
    }
    close OUT;
    return 1;
}


The output function just calls $world->note, and &__room_save saves a room.

I tested it out beforehand through the command line, and it saved the file perfectly. When I try to save when it's running as a PerlScript, everything returns correctly, but nothing is ever written.

I understand that there may be limitations on scripts that make them unable to read/write files... But, is there a way around this without having to open a log file and writing to it (if that will even work at all)?

Does this mean that the script can't read files either? Is there a workaround to reading files?
Australia Forum Administrator #1
You are pushing my knowledge of Perlscript here. I believe there are such things as limits on what scripts can do (ala read/write files) and there are also ways of disabling those limits, but I don't know what they are for Perlscript. Maybe browse the Perlscript site.
#2
Woah, I just tried it out again, and it's starting to save now. I haven't rebooted or anything, but maybe closing MUSHClient did it.

Hopefully this'll continue to work...