diff options
| author | fukachan <fukachan> | 2001-11-04 03:46:50 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-11-04 03:46:50 +0000 |
| commit | ba9f42bfd7fc509e25b0ce83d2f227d3a2494c0a (patch) | |
| tree | df7b003af939a5aad5ebf57b5a0f4c34161b8768 /fml/lib/FML | |
| parent | 0b5b1807f6511cf2996f698f5f52e99688f8fcba (diff) | |
| download | fml8-ba9f42bfd7fc509e25b0ce83d2f227d3a2494c0a.tar.gz fml8-ba9f42bfd7fc509e25b0ce83d2f227d3a2494c0a.tar.bz2 fml8-ba9f42bfd7fc509e25b0ce83d2f227d3a2494c0a.zip | |
save $args at $curproc->{ __parent_args }
$curproc provides convenient functions FML::Process::Utils has.
fml_version()
myname()
command_line_raw_argv()
command_line_argv()
article_id_max()
Diffstat (limited to 'fml/lib/FML')
| -rw-r--r-- | fml/lib/FML/Process/Kernel.pm | 8 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Utils.pm | 106 |
2 files changed, 113 insertions, 1 deletions
diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm index 7906ee7f..388724c3 100644 --- a/fml/lib/FML/Process/Kernel.pm +++ b/fml/lib/FML/Process/Kernel.pm @@ -4,13 +4,14 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Kernel.pm,v 1.58 2001/10/14 03:00:32 fukachan Exp $ +# $FML: Kernel.pm,v 1.59 2001/11/03 10:15:49 fukachan Exp $ # package FML::Process::Kernel; use strict; use Carp; +use vars qw(@ISA); =head1 NAME @@ -56,6 +57,7 @@ parameters. =cut use FML::Process::Flow; +use FML::Process::Utils; use FML::Parse; use FML::Header; use FML::Config; @@ -63,6 +65,9 @@ use FML::Log qw(Log LogWarn LogError); use File::SimpleLock; use FML::Messages; +# for small utilities: fml_version(), myname(), et. al. +push(@ISA, qw(FML::Process::Utils)); + # Descriptions: constructor # Arguments: $self $args # Side Effects: none @@ -113,6 +118,7 @@ sub new # for more convenience, save the parent configuration $curproc->{ main_cf } = $args->{ main_cf }; + $curproc->{ __parent_args } = $args; # bind FML::Config object to $curproc use FML::Config; diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm new file mode 100644 index 00000000..15e65e67 --- /dev/null +++ b/fml/lib/FML/Process/Utils.pm @@ -0,0 +1,106 @@ +#-*- perl -*- +# +# Copyright (C) 2001 Ken'ichi Fukamachi +# All rights reserved. This program is free software; you can +# redistribute it and/or modify it under the same terms as Perl itself. +# +# $FML: Utils.pm,v 1.8 2001/05/28 16:17:14 fukachan Exp $ +# + +package FML::Process::Utils; +use strict; +use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); +use Carp; +use FML::Log qw(Log LogWarn LogError); + + +=head1 NAME + +FML::Process::Utils - small utilities + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 TODO + +=head1 METHODS + +=cut + + +sub fml_version +{ + my ($curproc) = @_; + my $args = $curproc->{ __parent_args }; + + return $args->{ main_cf }->{ fml_version }; +} + + +sub myname +{ + my ($curproc) = @_; + my $args = $curproc->{ __parent_args }; + + return $args->{ myname }; +} + + +sub command_line_raw_argv +{ + my ($curproc) = @_; + my $args = $curproc->{ __parent_args }; + + return $args->{ argv }; +} + + +sub command_line_argv +{ + my ($curproc) = @_; + my $args = $curproc->{ __parent_args }; + + return $args->{ ARGV }; +} + + +sub article_id_max +{ + my ($curproc) = @_; + my $config = $curproc->{ config }; + my $seq_file = $config->{ sequence_file }; + my $id = undef; + + use FileHandle; + my $fh = new FileHandle $seq_file; + if (defined $fh) { + $id = $fh->getline(); + $id =~ s/^\s*//; $id =~ s/[\n\s]*$//; + $fh->close(); + } + + return( $id =~ /^\d+$/ ? $id : 0 ); +} + + +=head1 AUTHOR + +Ken'ichi Fukamachi + +=head1 COPYRIGHT + +Copyright (C) 2001 Ken'ichi Fukamachi + +All rights reserved. This program is free software; you can +redistribute it and/or modify it under the same terms as Perl itself. + +=head1 HISTORY + +FML::Process::Utils appeared in fml5 mailing list driver package. +See C<http://www.fml.org/> for more details. + +=cut + + +1; |
