| 1 | package DataFax; | ||
| 2 | |||
| 3 | # Perl standard modules | ||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Getopt::Std; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use POSIX qw(strftime); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | # use DataFax::Config qw(:all); | ||
| 9 | 0 | ▶ | use DataFax::StudyDB qw(:all); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 10 | use DataFax::StudySubs qw(:all); | ||
| 11 | |||
| 12 | our $VERSION = 0.10; | ||
| 13 | |||
| 14 | require Exporter; | ||
| 15 | our @ISA = qw(Exporter); | ||
| 16 | our @EXPORT = qw(); | ||
| 17 | our @IMPORT_OK = (@DataFax::StudyDB::EXPORT_OK, | ||
| 18 | @DataFax::StudySubs::EXPORT_OK | ||
| 19 | ); | ||
| 20 | our @EXPORT_OK = ('new', @IMPORT_OK); | ||
| 21 | our %EXPORT_TAGS = ( | ||
| 22 | # config => [@DataFax::Config::EXPORT_OK], | ||
| 23 | dfdb => [@DataFax::StudyDB::EXPORT_OK], | ||
| 24 | echo_msg => $DataFax::StudySubs::EXPORT_TAGS{echo_msg}, | ||
| 25 | param => $DataFax::StudySubs::EXPORT_TAGS{param}, | ||
| 26 | subs => [@DataFax::StudySubs::EXPORT_OK], | ||
| 27 | all => [@EXPORT_OK, @IMPORT_OK] | ||
| 28 | ); | ||
| 29 | |||
| 30 | =head1 NAME | ||
| 31 | |||
| 32 | DataFax - an DataFax object | ||
| 33 | |||
| 34 | =head1 SYNOPSIS | ||
| 35 | |||
| 36 | use DataFax; | ||
| 37 | |||
| 38 | my $cg = DataFax->new('ifn', 'my_init.cfg', 'opt', 'vhS:a:'); | ||
| 39 | |||
| 40 | =head1 DESCRIPTION | ||
| 41 | |||
| 42 | This is the base object for DataFax. | ||
| 43 | |||
| 44 | =cut | ||
| 45 | |||
| 46 | =head3 new (ifn => 'file.cfg', opt => 'hvS:') | ||
| 47 | |||
| 48 | Input variables: | ||
| 49 | |||
| 50 | ifn - input/initial file name. | ||
| 51 | opt - options for Getopt::Std | ||
| 52 | datafax_dir - full path to where DataFax system is installled | ||
| 53 | If not specified, it will try to get it from | ||
| 54 | $ENV{DATAFAX_DIR}. | ||
| 55 | datafax_host - DataFax server name or IP address | ||
| 56 | If not specified, it will try to get it from | ||
| 57 | $ENV{DATAFAX_HOST} or `hostname` on UNIX system. | ||
| 58 | |||
| 59 | Variables used or routines called: | ||
| 60 | |||
| 61 | None | ||
| 62 | |||
| 63 | How to use: | ||
| 64 | |||
| 65 | my $df = new DataFax; # or | ||
| 66 | my $df = DataFax->new; # or | ||
| 67 | my $df = DataFax->new(ifn=>'file.cfg',opt=>'hvS:'); # or | ||
| 68 | my $df = DataFax->new('ifn', 'file.cfg','opt','hvS:'); | ||
| 69 | |||
| 70 | Return: new empty or initialized DataFax object. | ||
| 71 | |||
| 72 | This method constructs a Perl object and capture any parameters if | ||
| 73 | specified. It creates and defaults the following variables: | ||
| 74 | |||
| 75 | ifn = "" | ||
| 76 | opt = 'hvS:' | ||
| 77 | datafax_dir = $ENV{DATAFAX_DIR} | ||
| 78 | datafax_host = $ENV{DATAFAX_HOST} | `hostname` | ||
| 79 | unix_os = 'linux|solaris' | ||
| 80 | |||
| 81 | =cut | ||
| 82 | |||
| 83 | sub new { | ||
| 84 | my $caller = shift; | ||
| 85 | my $caller_is_obj = ref($caller); | ||
| 86 | my $class = $caller_is_obj || $caller; | ||
| 87 | my $self = bless {}, $class; | ||
| 88 | my %arg = @_; # convert rest of inputs into hash array | ||
| 89 | foreach my $k ( keys %arg ) { | ||
| 90 | if ($caller_is_obj) { | ||
| 91 | $self->{$k} = $caller->{$k}; | ||
| 92 | } else { | ||
| 93 | $self->{$k} = $arg{$k}; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | $self->{ifn} = "" if ! exists $arg{ifn}; | ||
| 97 | $self->{opt} = 'hvS:' if ! exists $arg{opt}; | ||
| 98 | $self->{unix_os} = 'linux|solaris'; | ||
| 99 | $self->{datafax_dir} = "" if ! exists $self->{datafax_dir}; | ||
| 100 | $self->{datafax_host}= "" if ! exists $self->{datafax_host}; | ||
| 101 | $self->{datafax_dir} = $ENV{DATAFAX_DIR} | ||
| 102 | if exists $ENV{DATAFAX_DIR} && ! $self->{datafax_dir}; | ||
| 103 | $self->{datafax_host} = $ENV{DATAFAX_HOST} | ||
| 104 | if exists $ENV{DATAFAX_HOST} && ! $self->{datafax_host}; | ||
| 105 | $self->{datafax_host} = `hostname` | ||
| 106 | if ! $self->{datafax_host} && $^O =~ /^($self->{unix_os})/i; | ||
| 107 | return $self; | ||
| 108 | } | ||
| 109 | |||
| 110 | 1; | ||
| 111 | |||
| 112 | =head1 HISTORY | ||
| 113 | |||
| 114 | =over 4 | ||
| 115 | |||
| 116 | =item * Version 0.10 | ||
| 117 | |||
| 118 | This version is to set base for other DataFax classes. | ||
| 119 | |||
| 120 | =item * Version 0.20 | ||
| 121 | |||
| 122 | =cut | ||
| 123 | |||
| 124 | =head1 SEE ALSO (some of docs that I check often) | ||
| 125 | |||
| 126 | Oracle::Loader, Oracle::Trigger, CGI::Getopt, File::Xcopy, | ||
| 127 | DataFax, CGI::AppBuilder, etc. | ||
| 128 | |||
| 129 | =head1 AUTHOR | ||
| 130 | |||
| 131 | Copyright (c) 2005 Hanming Tu. All rights reserved. | ||
| 132 | |||
| 133 | This package is free software and is provided "as is" without express | ||
| 134 | or implied warranty. It may be used, redistributed and/or modified | ||
| 135 | under the terms of the Perl Artistic License (see | ||
| 136 | http://www.perl.com/perl/misc/Artistic.html) | ||
| 137 | |||
| 138 | =cut | ||
| 139 | |||