From 1a76d3373956ad2697c8768df4914e26d2859ad1 Mon Sep 17 00:00:00 2001 From: Angel Ortega Date: Fri, 21 Dec 2007 08:10:14 +0100 Subject: [PATCH] Adapted artemus script to new coding standards. --- artemus | 73 ++++++++++++++++++++++++++--------------------------------------- 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/artemus b/artemus index c43433f..9091448 100755 --- a/artemus +++ b/artemus @@ -87,7 +87,7 @@ $funcs{"shell"} = sub { $_=`$_[0]`; chop; return $_ }; $VERSION = $Artemus::VERSION; $artemus_id = "Artemus $VERSION"; -usage() if(!GetOptions( "i|input=s" => \$src, +usage() if (!GetOptions( "i|input=s" => \$src, "o|output=s" => \$dst, "c|conf=s" => \$config_file, "p|paragraph=s" => \$para_sep, @@ -110,8 +110,7 @@ make_makefile() if $makefile_template; build_site_map(@ARGV) if $site_map; -if(!$use_ftp) -{ +if (!$use_ftp) { usage() unless $src; usage() unless $dst; } @@ -149,8 +148,7 @@ open F, ($append ? ">" : "").">$dst" or die "can't write '$dst'"; print F $data; close F; -foreach my $t (@unresolved) -{ +foreach my $t (@unresolved) { print STDERR "Artemus: unresolved '$t'\n"; } @@ -164,43 +162,38 @@ sub read_config local (*F); # read config file - unless(open F, $conf) - { - if($quiet) - { return } - else - { die "'$conf' bad config file"; } + unless (open F, $conf) { + if($quiet) { + return; + } + else { + die "'$conf' bad config file"; + } } - while() - { - my ($key,$val); + while () { + my ($key, $val); chomp($_); - unless(/^#/ or /^$/) - { - ($key,$val) = split("=",$_,2); + unless (/^#/ or /^$/) { + ($key, $val) = split("=",$_,2); - if($val =~ s/^\|//) - { + if ($val =~ s/^\|//) { $val = `$val`; chop($val); } - elsif($val eq "<) - { + while () { last if /^EOF/; $val .= $_; } } - elsif($key eq "\\INCLUDE") - { + elsif ($key eq "\\INCLUDE") { read_config($val); next; } @@ -251,8 +244,7 @@ sub ftp_send require Net::FTP; - if(scalar(@ARGV) == 0) - { + if (scalar(@ARGV) == 0) { print "Nothing to send.\n"; exit(0); } @@ -266,8 +258,7 @@ sub ftp_send or die "ftp login error"; print "OK\n"; - if(defined($vars{'ftp.dir'})) - { + if (defined($vars{'ftp.dir'})) { print "Chdir $vars{'ftp.dir'}...\n"; $ftp->cwd($vars{'ftp.dir'}); print "OK\n"; @@ -275,8 +266,7 @@ sub ftp_send $ftp->binary(); - foreach my $f (@ARGV) - { + foreach my $f (@ARGV) { print "Sending $f...\n"; $ftp->put($f,$f); print "OK\n"; @@ -367,14 +357,12 @@ sub build_site_map print "{-site-map-head}\n\n"; print "
    \n"; - foreach my $dir (@dirs) - { - my ($cnt,@l); + foreach my $dir (@dirs) { + my ($cnt, @l); open F, "find $dir -name \"*.html\" -follow|" or next; - while() - { + while () { chop; s/^\.\///; push(@l,$_) unless /index.html$/; @@ -389,9 +377,8 @@ sub build_site_map # travel the list $cnt = 0; - foreach my $i (@l) - { - my ($size,$file,$title); + foreach my $i (@l) { + my ($size, $file, $title); $size = -s $i; @@ -400,12 +387,10 @@ sub build_site_map $file = join("",); close F; - if ($file =~ /([^<]*)/i) - { + if ($file =~ /<title>([^<]*)/i) { $title = $1; } - else - { + else { $title = $i; } -- 2.11.4.GIT