>>What exactly does this error message mean?
>>
>># No such signal: SIGPIPE.
>>File 'Wild Colonials:Applications:MacPerl (5.20r4):site_perl:Net:Cmd.pm'; Line
>>169
>
>It means exactly what it says. There's no such signal SIGPIPE (a Unix 
>thing) in Mac OS, and Net::Cmd attempts to set $SIG{PIPE}.  You can 
>either ignore the warning or comment out the $SIG{PIPE} assignment


New question, Will it still work? See I have a loop (something like for 0..353 )
and this error only starts up about halfway/thirdway through the loop, the first
many times go fine.

My script is for reading through a flat database to create html and FTPing them
to my website via Net::FTP. I suppose now'd be a good time to show the code,
beware email linewraps; feel free to comment on other style/corrections

~wren

#!perl -w
use Net::FTP;
# POWGenerater, v2.300
# 
# Main Variables
#    $counter                              total number of quotes
#    $home                                 relative url to main index sans .html
#    $root_url                             absolute url to working directory
sans /
#    %entry{FIELD}[0..$counter-1] = VALUE; database from ~DB.txt
#    @category[0..$category-1]             ordered list of categories,
circumfixed
#    @names[0..$names-1] = SURNAME;        alphabetized list of surnames,
circumfixed
#    %names{SURNAME}                       space delimited quote #s by SURNAME
#
################################################################################
## #
$| = 1;
$home = '../index';
$category = @category = ($home,
 'proverb', 'rome', 'greek', 'bus', 
        'friend', 'love', 'malk', 'wisdom', 'self', 'truth', 'art', 'time', 'god',
'last', 
        $home);
$root_url = 'http://cronus.spaceports.com/~phreelan/pow';
# $root_url = $ftp->pwd() or print "'pwd' error:$!\n";

print '#'x60, "\n\nSigning on . . . ";
$ftp = Net::FTP->new('cronus.spaceports.com', 'port' => 21) or print "error
creating object:$!\n";
$ftp->login('phreelan', 'WEBbRanf') or print "login failed:$!\n";
$ftp->cwd('public_html/pow/') or print "'cwd' command failed:$!\n";
print "connected to ftp server\n";
#
################################################################################
## #
print 'Reading DB . . . ';
$counter = 0;
open(DB, '<~DB.txt') or print "error opening '~DB.txt':$!\n";
while(<DB>){
        my $line = $_;
        my @fields = ('forename', 'surname', 'postname', 'where', 'quote',
'translation', 'category');
        foreach(@fields) {
                $line =~ /\[$_\>\t(.*?)\t/;
                chomp($entry{$_}[$counter] = $1);
        }
        $counter++;
}
close DB;
print "read $counter quotes\n";
#
################################################################################
## #
print 'Making personal pages . . . ';
foreach(0..$counter-1) { $names{$entry{'surname'}[$_]} .= " $_" }
$names = @names = ($home, sort(keys %names), $home);
open(DB, '>~DB.txt') or print "error opening '~DB.txt':$!\n";
foreach(1..$names-2){
        $last    = &url($names[$_-1]);
        my $file = &url($names[$_]);
        $next    = &url($names[$_+1]);
        open(OUT, '>temp.txt') or print "error opening 'temp.txt':$!\n";
        &print_header('../', $last, $next);
        foreach(split ' ', $names{$names[$_]}) {
                my $quote = $_;
                my @fields = ('forename', 'surname', 'postname', 'where', 'quote',
'translation', 'category');
                foreach(@fields) {
                        print DB "\[$_\>\t$entry{$_}[$quote]\t";
                }
                print DB "\n";
                &print_quote('../')
        }
        &print_footer('../', $last, $next);
        close OUT;
        $ftp->put('temp.txt', $file) or &error($file);
        print '.';
}
close DB;
print "\npersonals done and DB sorted\n";
#
################################################################################
## #
print 'Making index page . . . ';
open(RANDOM, '>random.txt') or print "error opening 'random.txt':$!\n";
open(OUT, '>temp.txt') or print "error opening 'temp.txt':$!\n";
&print_header('', "$home.html", "$home.html");
my @date = localtime;
my @day = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
'Saturday');
my @month = ('January', 'Febuary', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December');
$date[5] += 1900;
print OUT "<center>As of $day[$date[6]], $date[3] $month[$date[4]] $date[5]
there are $counter quotes</center><br><table align=center width=720><tr>";
my $col = 0;
foreach(1..$names-2){
        my $url = &url($names[$_]);
        print OUT "<td width=90><font size=-1><a href=\"$url\">";
        print RANDOM "$root_url/$url\n";
        print OUT "$names[$_]</a></font></td>\n";
        $col++;
        if($col > 7) { print OUT '</tr><tr>'; $col = 0; }
}
print OUT '</tr></table>';
&print_footer('', "$home.html", "$home.html");
close OUT;
$ftp->put('temp.txt', 'index.html') or &error('index.html');
close RANDOM;
print "index and random done\n";
#
################################################################################
## #
print 'Making category pages . . . ';
foreach(1..$category-2){
        my $i = $_;
        open(OUT, '>temp.txt') or print "error opening 'temp.txt':$!\n";
        &print_header('', "$category[$i-1].html", "$category[$i+1].html");
        foreach(0..$counter-1) {
                &print_quote('') if $entry{'category'}[$_] =~ /$category[$i]/;
        }
        &print_footer('', "$category[$i-1].html", "$category[$i+1].html");
        close OUT;
        $ftp->put('temp.txt', "$category[$i].html") or &error("$category[$i].html");
        print '.';
}
print "\ncategories done\n";
#
################################################################################
## #
$ftp->quit();
print "\nSigned off, Finished.";
<STDIN>;

#
################################################################################
## #
# ####################### returns relative SURNAME.html url
######################## #
sub url {
        my $url = substr($_[0], 0, 1)."/$_[0].html";
        $url =~ tr/ /_/;
        return $url;
}
# ############################## returns file error
################################ #
sub error { print "\aerror creating file '$_[0]':$!\npaused"; <STDIN>;}
# ############################# prints the page header
############################# #
sub print_header {
$header = <<END__HEADER ;
<html>
<head><title>Pearls of Wisdom</title></head>
<body bgcolor="#000000" text="beige" link="#dddddd" vlink="#999999">
<!--#spaceportsbanner-->
<table width=350 align=center><tr><td>
<p align=center>
<a href="$_[0]$home.html"><img src="$_[0]../main_resources/pow2.jpg" width=350
height=54 border=0></a><br>
[ <a href="$_[0]$_[1]" style="text-decoration:none">&lt; &lt;</a> 
<a href="$_[0]index.html" style="text-decoration:none">p o w</a> 
<a href="$_[0]$_[2]" style="text-decoration:none">&gt; &gt;</a> ]
</p>
END__HEADER
print OUT $header;
}
# ################################# prints a quote
################################# #
sub print_quote {
        $entry{'quote'}[$_] =~ s/ \/ /<br>/g;
        if ($entry{'quote'}[$_] =~ /^\&\&/) {
                my $quote = $entry{'quote'}[$_];
                $quote =~ s/^\&\&//;
                print OUT "\"<font face=\"symbol\">$quote</font>\"<br>\n";
        } else {
                print OUT "\"$entry{'quote'}[$_]\"<br>\n";
        }
        print OUT "\'<i>$entry{'translation'}[$_]</i>\'<br>\n" if
$entry{'translation'}[$_];
        my $url = &url($entry{'surname'}[$_]);
        print OUT "<p align=right><i>~<a href=\"$_[0]$url\"><font
color=\"#dddddd\">$entry{'forename'}[$_] $entry{'surname'}[$_]";
        print OUT " $entry{'postname'}[$_]" if $entry{'postname'}[$_];
        print OUT "</font></a><br><font color=\"#dddddd\">\n";
        print OUT "$entry{'where'}[$_]<br>\n" if $entry{'where'}[$_];
        print OUT "</i></font></p><br>\n";
}
# ############################# prints the page footer
############################# #
sub print_footer {
$footer = <<END__FOOTER ;
<p align=center>
[ <a href="$_[0]$_[1]" style="text-decoration:none">&lt; &lt;</a> 
<a href="$_[0]index.html" style="text-decoration:none">p o w</a> 
<a href="$_[0]$_[2]" style="text-decoration:none">&gt; &gt;</a> ]
<br><a href="mailto:phreelance\@mad.scientist.com"><img
src="$_[0]../main_resources/sig.jpg" border=0 width=50 height=50 alt="[ email me
]"></a></p>
</tr></td></table>
</body>
</html>
END__FOOTER
print OUT $footer;      
}

Reply via email to