"Fossies" - the Fresh Open Source Software Archive

Member "absence-v2.1/utils/load-regions.pl" (20 Oct 2013, 1732 Bytes) of package /linux/www/web-absence-2.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "load-regions.pl" see the Fossies "Dox" file reference documentation.

    1 #!/usr/bin/perl
    2 
    3 #======================================================================
    4 #    This file is part of Absence.
    5 #
    6 #    Absence is free software: you can redistribute it and/or modify
    7 #    it under the terms of the GNU General Public License as published by
    8 #    the Free Software Foundation, either version 3 of the License, or
    9 #    (at your option) any later version.
   10 #
   11 #    Absence is distributed in the hope that it will be useful,
   12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 #    GNU General Public License for more details.
   15 #
   16 #    You should have received a copy of the GNU General Public License
   17 #    along with Absence.  If not, see <http://www.gnu.org/licenses/>.
   18 #======================================================================
   19 
   20 # copyright Robert Urban
   21 
   22 use FileHandle;
   23 use Getopt::Long;
   24 
   25 use AbsenceImport;
   26 #use AbsenceMigration;
   27 
   28 my $DEBUG = 1;
   29 my $in_file;
   30 
   31 my ($db_user, $db_pass, $db_host, $db_name);
   32 
   33 my $res = GetOptions(
   34     'file|f=s'  => \$in_file,
   35     'user|u=s'  => \$db_user,
   36     'pass|p=s'  => \$db_pass,
   37     'host|h=s'  => \$db_host,
   38     'name|n=s'  => \$db_name,
   39 );
   40 
   41 defined($in_file) || die "usage: $0 -file <input-file>\n";
   42 (!defined($db_user) || !defined($db_pass) || !defined($db_host) ||
   43     !defined($db_name)) && die "DB user/pass/host/name missing\n";
   44 
   45 
   46 my $fh = FileHandle->new($in_file);
   47 defined($fh) || die "could not open file [$in_file]: $!";
   48 
   49 my @regions;
   50 while(<$fh>) {
   51     chomp;
   52     push(@regions, $_);
   53 }
   54 $fh->close;
   55 
   56 AbsenceImport::init($db_user, $db_pass, $db_name, $db_host);
   57 
   58 foreach my $region (@regions) {
   59     $DEBUG && print "region=[$region]\n";
   60     AbsenceImport::createRegion($region);
   61 }