sub cmdline { # print command line arguments $args_length = $#ARGV + 1; print "$args_length\n"; foreach $arg (0 .. $#ARGV) { print "$ARGV[$arg]\n"; } } #--------------------------------------------------------------------------- sub getdate { my($datecmd) = "/bin/date"; my($date) = `$datecmd +"%B %d, %Y"`; chop($date); return $data; } #--------------------------------------------------------------------------- sub getimage { my($image) = @_ if @_; print "Content-Type: image/gif\n\n"; open(GIF,"<$image") || die "Can't open $image\n"; while(read(GIF,$buf,16384)) { print $buf; } } #--------------------------------------------------------------------------- $mailLoc = "/usr/lib/sendmail"; $mailTo = "abc\@isp.com"; sub sendmail { open (mail, "| $mailLoc $mailTo") || die "Can't open $mailLoc!\n"; print mail "Reply-to: $theForm{'email'} ($theForm{'name'})\n"; print mail "From: $theForm{'email'} ($theForm{'name'})\n"; print mail "Subject: Signed Camping Guestbook\n\n"; print mail "$theForm{'comments'}\n\n"; print mail "$theForm{'location'}\n\n"; print mail "$date\n"; close (mail); } #--------------------------------------------------------------------------- sub findline { # findline(buffer,string) local($buf,$str) = @_ if @_; local($bufl,@lbuf,$i,$j); @lbuf = split(/\n/,$buf); $bufl = @lbuf; $j = 0; foreach $i (@lbuf) { if($i =~ $str) { return $j; } $j++; } return 0; } #--------------------------------------------------------------------------- sub getBuf { # returns file data local($file) = @_ if @_; local($buf,$i); open (FILE,"$file") || die "Can't Open $file:\n"; @file =; close (FILE); foreach $i (@file) { $buf .= $i; } return $buf; } #--------------------------------------------------------------------------- sub getHTML { # getHTML(data,begining,ending) # returns DATA between $beg STRING and $end STRING. local($buf,$beg,$end) = @_ if @_; local(@lbuf,$i,$j); @lbuf = split(/\n/,$buf); $j = 0; $buf = ""; foreach $i (@lbuf) { if($j>=$beg && $j<=$end) { if($j != $end) { $buf .= "$i\n"; } else { $buf .= $i; } } $j++; } return $buf; }