Halo,
I have this script and I want to run it on a cacm.all collection but I become always this error:
perl split.pl cacm.all
Can´t call Method "print" on an undefined value at split.pl line 49, <> line 1
I think the code is right but IO::Fileworks probably not on my PC.
The cacm.all data is here
Is the Script ok? If that script runs on your PC, please pack and upload the document collection on rapidshare. Ireallyneed the document collection splitet for one application.
Thank you very much
The Perl Script code:
#!/usr/sw/perl/default/bin/perl
######################### -*- Mode: Perl -*- #########################
##
## File : $RCSfile$
##
##
## Created On : Thu Dec 12 18:40:50 2002
## Last Modified : Time-stamp: <2002-12-21 21:46:42 kai>
##
## Description :
##
## $Id$
##
######################################################################
use strict;
use warnings;
use Pod::Usage;
use Getopt::Long;
use IO::File;
our $VERSION;
'$Name$ 0_0' =~ /(\d+)[-_](\d+)/; $VERSION = sprintf '%d.%03d', $1, $2;
my %OPT = ();
GetOptions( \%OPT,
# default options
qw( help
version
),
# application specific options
qw()
) or pod2usage(2);
pod2usage(VERBOSE => 2) if $OPT{help};
print $VERSION, "\n" and exit if $OPT{version};
my $d = ''; # document
my $n = 0; # number
while (<>) {
if (m(^\.I)) {
# beginning of document
my $fname = sprintf("doc/%04d", $n);
my $f = IO::File->new($fname, "w");
$f->print($d);
$f->close();
$d = '';
$n++;
} elsif (m(^\.)) {
# other header line; "@" does not occur in cacm.all
s(^\.)(@);
$d .= $_;
} else {
# append line
$d .= $_;
}
}
# write out last document
my $fname = sprintf("doc/%04d", $n);
my $f = IO::File->new($fname, 'w');
$f->print($d);
$f->close();
## ###################################################################
## subs
## ###################################################################
__END__
## ###################################################################
## pod
## ###################################################################
=head1 NAME
split.pl - Kai Großjohann is too lazy to provide a description?!
=head1 SYNOPSIS
B<split.pl>
[B<-help>] [B<-version>]
[B<file>...]
=head1 DESCRIPTION
Read C<cacm.all> format from the given files or from standard input.
Output is written to the F<doc> subdir, one document per file.
Files are named after the document number. The C<.I> line is not
written to the output files. The field indicators like C<.W> are
rewritten to use the at sign instead of dot, as in C<@W>.
=head1 OPTIONS
Option names may be abbreviated to uniqueness.
=over
=item B<-help>
Show this manual.
=item B<-version>
Show program version.
=back
=head1 EXAMPLES
% split.pl cacm/cacm.all
has the effect of writing files F<doc/0001> through F<doc/3338>, where
each file contains one document.
=head1 BUGS
Yes. Please let me know!
=head1 SEE ALSO
perl(1).
=cut
I have this script and I want to run it on a cacm.all collection but I become always this error:
perl split.pl cacm.all
Can´t call Method "print" on an undefined value at split.pl line 49, <> line 1
I think the code is right but IO::Fileworks probably not on my PC.
The cacm.all data is here
Is the Script ok? If that script runs on your PC, please pack and upload the document collection on rapidshare. Ireallyneed the document collection splitet for one application.
Thank you very much
The Perl Script code:
#!/usr/sw/perl/default/bin/perl
######################### -*- Mode: Perl -*- #########################
##
## File : $RCSfile$
##
##
## Created On : Thu Dec 12 18:40:50 2002
## Last Modified : Time-stamp: <2002-12-21 21:46:42 kai>
##
## Description :
##
## $Id$
##
######################################################################
use strict;
use warnings;
use Pod::Usage;
use Getopt::Long;
use IO::File;
our $VERSION;
'$Name$ 0_0' =~ /(\d+)[-_](\d+)/; $VERSION = sprintf '%d.%03d', $1, $2;
my %OPT = ();
GetOptions( \%OPT,
# default options
qw( help
version
),
# application specific options
qw()
) or pod2usage(2);
pod2usage(VERBOSE => 2) if $OPT{help};
print $VERSION, "\n" and exit if $OPT{version};
my $d = ''; # document
my $n = 0; # number
while (<>) {
if (m(^\.I)) {
# beginning of document
my $fname = sprintf("doc/%04d", $n);
my $f = IO::File->new($fname, "w");
$f->print($d);
$f->close();
$d = '';
$n++;
} elsif (m(^\.)) {
# other header line; "@" does not occur in cacm.all
s(^\.)(@);
$d .= $_;
} else {
# append line
$d .= $_;
}
}
# write out last document
my $fname = sprintf("doc/%04d", $n);
my $f = IO::File->new($fname, 'w');
$f->print($d);
$f->close();
## ###################################################################
## subs
## ###################################################################
__END__
## ###################################################################
## pod
## ###################################################################
=head1 NAME
split.pl - Kai Großjohann is too lazy to provide a description?!
=head1 SYNOPSIS
B<split.pl>
[B<-help>] [B<-version>]
[B<file>...]
=head1 DESCRIPTION
Read C<cacm.all> format from the given files or from standard input.
Output is written to the F<doc> subdir, one document per file.
Files are named after the document number. The C<.I> line is not
written to the output files. The field indicators like C<.W> are
rewritten to use the at sign instead of dot, as in C<@W>.
=head1 OPTIONS
Option names may be abbreviated to uniqueness.
=over
=item B<-help>
Show this manual.
=item B<-version>
Show program version.
=back
=head1 EXAMPLES
% split.pl cacm/cacm.all
has the effect of writing files F<doc/0001> through F<doc/3338>, where
each file contains one document.
=head1 BUGS
Yes. Please let me know!
=head1 SEE ALSO
perl(1).
=cut