Input.pm

wiley_dist/src/convert/perl/MudConvert/DUMP/Input.pm · 641 B

From the archive WileyMUD3_091205.tar.bz2

Download the archive   « Back to the archive contents

#!/usr/bin/perl -w

package MudConvert::DUMP::Input;

use strict;
use English;
use Data::Serializer;

use base 'Exporter';

our @EXPORT_OK = qw( load_game );

sub load_game {
  my $cfg = shift;
  my $dump = Data::Serializer->new();

  my $dump_dir = $cfg->{'source-dir'};
  my $dump_file = "$dump_dir/data.dump";

  if( (! -d $dump_dir) or (! -r $dump_file) or !(open FOO, $dump_file) ) {
    printf STDERR "FATAL: Cannot open input DUMP file (%s) for DUMP!\n", $dump_file;
    return undef;
  }
  my @lines = ();
  push @lines, $_ while(<FOO>);
  close FOO;
  my $input_data = $dump->thaw(join("", @lines));
  
  return $input_data;
}

1;

Site Stats

Snippets: 1791
Codebases: 571