[18550] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 718 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 19 09:41:35 2001

Date: Thu, 19 Apr 2001 06:41:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <987687673-v10-i718@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 19 Apr 2001     Volume: 10 Number: 718

Today's topics:
        Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
        submission script help! <iou4evr@excite.com>
    Re: submission script help! (David Efflandt)
        subroutine prototypes and require question <donovan@ifa.hawaii.edu>
        svript wont run this is perl -w output help? <r.borkent@123chello.nl>
    Re: svript wont run this is perl -w output help? <jjfreeman@bigpond.com>
    Re: svript wont run this is perl -w output help? <bart.lateur@skynet.be>
    Re: Thanks, and another clue <temp133@hotmail.com>
    Re: Thanks, and another clue <uri@sysarch.com>
        The return value takes no notice about the perfect matc <kalle@tvettsvamp.a.se>
    Re: The return value takes no notice about the perfect  <bart.lateur@skynet.be>
    Re: The return value takes no notice about the perfect  (Gwyn Judd)
    Re: Time Intervals Question <mmortonallen@csu.edu.au>
    Re: Time Intervals Question (Dave Bailey)
    Re: Tizek.com is in dire need of a development team... <uri@sysarch.com>
        using SYSTEM to run progs <Martin.Bower@ib.bankgesellschaft.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 16 Apr 2001 13:40:51 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <tdltj3s7c4l832@corp.supernews.com>

Following is a summary of articles spanning a 7 day period,
beginning at 09 Apr 2001 14:44:20 GMT and ending at
16 Apr 2001 13:45:00 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 2001 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Excluded Posters
================

perlfaq-suggestions\@(?:.*\.)?perl\.com
faq\@(?:.*\.)?denver\.pm\.org

Totals
======

Posters:  299
Articles: 1037 (485 with cutlined signatures)
Threads:  263
Volume generated: 1961.2 kb
    - headers:    880.8 kb (16,723 lines)
    - bodies:     1009.6 kb (33,219 lines)
    - original:   622.1 kb (22,333 lines)
    - signatures: 69.8 kb (1,578 lines)

Original Content Rating: 0.616

Averages
========

Posts per poster: 3.5
    median: 2 posts
    mode:   1 post - 136 posters
    s:      6.0 posts
Posts per thread: 3.9
    median: 3 posts
    mode:   1 post - 75 threads
    s:      5.0 posts
Message size: 1936.6 bytes
    - header:     869.8 bytes (16.1 lines)
    - body:       996.9 bytes (32.0 lines)
    - original:   614.3 bytes (21.5 lines)
    - signature:  68.9 bytes (1.5 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   38    63.5 ( 27.7/ 30.6/ 14.3)  Jonathan Stowe <gellyfish@gellyfish.com>
   38    91.1 ( 39.0/ 40.8/ 19.7)  Uri Guttman <uri@sysarch.com>
   35    50.9 ( 30.6/ 20.0/ 11.6)  Bart Lateur <bart.lateur@skynet.be>
   31    45.3 ( 23.0/ 20.0/ 11.7)  nobull@mail.com
   30    57.7 ( 26.7/ 22.1/ 17.3)  Mark Jason Dominus <mjd@plover.com>
   27    57.9 ( 22.4/ 33.3/ 21.7)  Logan Shaw <logan@cs.utexas.edu>
   26    51.1 ( 21.0/ 30.1/ 11.9)  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
   21    48.2 ( 20.5/ 24.8/ 24.0)  abigail@foad.org
   20    32.8 ( 15.9/ 13.8/  8.1)  Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
   19    48.6 ( 20.4/ 28.0/ 22.0)  "Alan J. Flavell" <flavell@mail.cern.ch>

These posters accounted for 27.5% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

  91.1 ( 39.0/ 40.8/ 19.7)     38  Uri Guttman <uri@sysarch.com>
  63.5 ( 27.7/ 30.6/ 14.3)     38  Jonathan Stowe <gellyfish@gellyfish.com>
  57.9 ( 22.4/ 33.3/ 21.7)     27  Logan Shaw <logan@cs.utexas.edu>
  57.7 ( 26.7/ 22.1/ 17.3)     30  Mark Jason Dominus <mjd@plover.com>
  51.1 ( 21.0/ 30.1/ 11.9)     26  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
  50.9 ( 30.6/ 20.0/ 11.6)     35  Bart Lateur <bart.lateur@skynet.be>
  48.6 ( 20.4/ 28.0/ 22.0)     19  "Alan J. Flavell" <flavell@mail.cern.ch>
  48.2 ( 20.5/ 24.8/ 24.0)     21  abigail@foad.org
  45.3 ( 23.0/ 20.0/ 11.7)     31  nobull@mail.com
  40.4 ( 20.7/ 17.0/  9.5)     19  tadmc@augustmail.com

These posters accounted for 28.3% of the total volume.

Top 10 Posters by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.999  ( 11.1 / 11.1)     10  "Scott R. Godin" <webmaster@webdragon.unmunge.net>
0.970  ( 24.0 / 24.8)     21  abigail@foad.org
0.915  (  4.4 /  4.8)      6  "Robb Meade" <robbie@DONTgoofymouseSPAM.freeserve.co.uk>
0.846  (  7.3 /  8.6)      9  "Karl Young" <karlyoung@unconscious.co.uk>
0.815  (  4.5 /  5.6)      5  "Milliwave" <milliwave@rfengineering.freeserve.co.uk>
0.784  ( 22.0 / 28.0)     19  "Alan J. Flavell" <flavell@mail.cern.ch>
0.783  ( 17.3 / 22.1)     30  Mark Jason Dominus <mjd@plover.com>
0.746  (  4.4 /  5.9)      7  Rafael Garcia-Suarez <rgarciasuarez@free.fr>
0.732  ( 12.9 / 17.7)      6  mgjv@tradingpost.com.au
0.723  (  3.0 /  4.2)      5  Steve K. Brown <skbrown@vcd.hp.com>

Bottom 10 Posters by OCR (minimum of five posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.428  (  3.0 /  6.9)      9  Cameron Dorey <camerond@mail.uca.edu>
0.414  (  2.7 /  6.5)      8  bernard.el-hagin@lido-tech.net
0.394  ( 11.9 / 30.1)     26  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
0.392  (  1.7 /  4.3)      5  garry@zvolve.com
0.385  (  1.8 /  4.7)      5  tuxy <nospam@cfl.rr.com>
0.384  (  3.0 /  7.8)      5  "speakeasy" <artd@speakeasy.net>
0.377  (  6.4 / 17.0)     11  "Roman Filippov" <NO_SPAM_klubbheads@home.com>
0.325  (  3.5 / 10.8)     10  shb@vnet.net
0.296  (  4.9 / 16.5)      7  "Chris A." <chris62vw@hotmail.com>
0.218  (  2.2 / 10.0)     12  "John W. Krahn" <krahnj@acm.org>

50 posters (16%) had at least five posts.

Top 10 Threads by Number of Posts
=================================

Posts  Subject
-----  -------

   37  Laziness, Impatience and Hubris  :-)
   36  complaint about moderation of this group
   30  A CGI question
   23  inheritance within one file?
   22  How can u group together fields and sum them up
   21  Flame Target
   19  So what do YOU use Perl for?
   18  How to redirect between STDOUT and a file?
   17  Beta Testers/Perl Hackers
   17  save a value of a variable between subroutines run... (++)

These threads accounted for 23.1% of all articles.

Top 10 Threads by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Subject
--------------------------  -----  -------

  94.2 ( 37.2/ 53.0/ 35.3)     36  complaint about moderation of this group
  85.7 ( 46.5/ 34.8/ 18.8)     37  Laziness, Impatience and Hubris  :-)
  64.8 ( 27.6/ 35.2/ 22.3)     30  A CGI question
  49.1 ( 22.6/ 22.8/ 15.5)     23  inheritance within one file?
  45.5 ( 12.8/ 31.7/ 20.4)     17  Beta Testers/Perl Hackers
  44.2 ( 17.8/ 24.0/ 14.8)     22  How can u group together fields and sum them up
  37.6 ( 15.8/ 20.6/ 10.4)     17  save a value of a variable between subroutines run... (++)
  36.7 ( 18.7/ 16.9/ 10.6)     21  Flame Target
  32.5 ( 16.2/ 14.7/  9.3)     19  So what do YOU use Perl for?
  32.1 ( 10.2/ 21.8/ 16.9)     11  unicode, perl and webbrowsers

These threads accounted for 26.6% of the total volume.

Top 10 Threads by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.826  (  5.6/   6.7)      6  Why is finish() necessary here with DBI? Bug in DBD::ODBC?
0.819  (  7.2/   8.8)      8  CGI.pm V. Here Docs . . .
0.804  (  5.2/   6.4)      9  Easy Perl Question...
0.804  (  5.1/   6.4)     10  changing @INC permenently
0.787  (  6.1/   7.7)      9  using dup()
0.775  ( 16.9/  21.8)     11  unicode, perl and webbrowsers
0.751  (  3.3/   4.4)      6  how to improve this code?
0.746  ( 12.9/  17.3)      9  perl hacker wanted
0.735  (  4.9/   6.7)      5  Forking a process
0.704  (  2.7/   3.9)      6  SV: perl equivalent for (char) long_var in C ?

Bottom 10 Threads by OCR (minimum of five posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.503  ( 10.4 / 20.6)     17  save a value of a variable between subroutines run... (++)
0.502  (  1.9 /  3.8)      5  LWP - HTTPS
0.461  (  2.5 /  5.3)      7  How can I use a variable variable name?
0.460  (  4.4 /  9.6)      7  One liner - how ?
0.457  (  3.9 /  8.6)      8  $text in a text file - how do I get it to print?
0.446  (  2.3 /  5.2)      6  [Fwd: help a perl newbie with script]
0.429  (  5.0 / 11.6)     10  registration script
0.420  (  3.3 /  7.7)      9  Executing Perl script from C or C++ program.
0.368  (  4.1 / 11.1)     10  CGI.PM and Forms
0.355  (  2.6 /  7.2)      6  for each loop

62 threads (23%) had at least five posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      16  comp.lang.perl.moderated
      13  comp.lang.perl.modules
      12  alt.perl
      10  comp.lang.tcl
       9  comp.programming
       9  comp.mail.misc
       3  de.comp.lang.perl.misc
       2  alt.comp.perlcgi.freelance
       2  comp.lang.perl
       2  de.comp.lang.perl.cgi

Top 10 Crossposters
===================

Articles  Address
--------  -------

      10  Mark Jason Dominus <mjd@plover.com>
       7  Logan Shaw <logan@cs.utexas.edu>
       7  "Jan Klunder" <jklunder@xs4all.nl>
       6  "Markus Elfring" <ELF@Messer.de>
       5  brian d foy <comdog@panix.com>
       3  Jeffrey Hobbs <JeffH@ActiveState.com>
       3  Phil Holland <postmaster@hollandnumerics.co.uk>
       3  Cameron Laird <claird@starbase.neosoft.com>
       3  Darren New <dnew@san.rr.com>
       3  "Simon Whittaker" <simonNOSPAM@swbh.net>


------------------------------

Date: Tue, 17 Apr 2001 15:36:38 GMT
From: "Kat" <iou4evr@excite.com>
Subject: submission script help!
Message-Id: <aqZC6.4874$q51.45183@news1.gvcl1.bc.home.com>

Hi,

I am trying to get an assignment submission script.  I cannot get the script
to setuid properly.  Everytime I test it the owner of the directory and file
belong to "nobody".  I was told to use a c wrapper so I have one that
hopefully gets the uid but I do not know how to use it.  In the c file there
is a call to the perl script.  Now, where to make this call to the c file?
Do I put it in the call to the script itself on the form or is there
something else I have to do?  Any help would be greatly appreciated.


a.k.a  Kat




------------------------------

Date: Wed, 18 Apr 2001 04:56:20 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: submission script help!
Message-Id: <slrn9dq7jk.jc6.see-sig@typhoon.xnet.com>

On Tue, 17 Apr 2001 15:36:38 GMT, Kat <iou4evr@excite.com> wrote:
> 
> I am trying to get an assignment submission script.  I cannot get the script
> to setuid properly.  Everytime I test it the owner of the directory and file
> belong to "nobody".  I was told to use a c wrapper so I have one that
> hopefully gets the uid but I do not know how to use it.  In the c file there
> is a call to the perl script.  Now, where to make this call to the c file?
> Do I put it in the call to the script itself on the form or is there
> something else I have to do?  Any help would be greatly appreciated.

You would submit the form to the suid C wrapper, which in turn should call
the script as that uid.  Of course it would be easier if you found a web 
host that runs cgiwrap or apache suexec so all your CGI would run as you.

Or you could try using 'suidperl' instead of 'perl' in the first line of
the script and see if you can do away with the C wrapper.  But first read
perldoc perlsec about untainting input and the environment.

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


------------------------------

Date: Thu, 19 Apr 2001 02:03:01 -1000
From: David Donovan <donovan@ifa.hawaii.edu>
Subject: subroutine prototypes and require question
Message-Id: <3ADED3F5.FF6FFE93@ifa.hawaii.edu>

Hi all,

I'm trying to place a subroutine definition with prototypes like

sub mysub(\%) {
    perl code here;
}

in a separate file which will be "require"d by my main perl script.
however,
it seems that in order for the subroutine to work, i need to declare it
first before i use it in the main script,
sort of like as in c ...
so i have

sub mysub(\%);
mysub(%myhash);

i'd like to place the declaration in the file that is "require"d , but
it doesn't seem to be working..
i don't really understand, because I thought the entire perl script in
the "require" is executed first, so
technically i think that I shouldn't need to declare it in the main
script.  i guess it's not really that big
of a deal, but i'm wondering if this is a bug in perl or something
fundamental i'm misunderstanding about
require or subroutine prototypes.  incidentally, if i'm not using a
prototype and i do:

mysub(\%myhash);

it works fine.  any insights?

thanks,

david donovan
ps i'm using perl version 5.004_04 built for sun4-solaris



------------------------------

Date: Mon, 16 Apr 2001 14:05:42 GMT
From: RonB <r.borkent@123chello.nl>
Subject: svript wont run this is perl -w output help?
Message-Id: <3ADAFE07.9020905@123chello.nl>

I cant seem to get scripts working under the cgi-bin. My testperl.pl 
does what it is supposed to do, say hello, but all my other scripts run 
in to the premature end of header....bla.
this is the output with the perl -w command. By the way, this script 
works fine on my remotely hosted site.
Please help, any suggestion will be welcome.

bash-2.04# perl -w newspro.cgi
Name "main::nplang_DateFormat" used only once: possible typo at 
newspro.cgi line 1502.
Name "main::SilentBuild" used only once: possible typo at newspro.cgi 
line 970.
Name "main::newsdate" used only once: possible typo at newspro.cgi line 
1119.
Name "main::ArcHtmlExt" used only once: possible typo at newspro.cgi 
line 801.
Name "main::ChangedItems" used only once: possible typo at newspro.cgi 
line 1228.
Name "main::EnableDailyArchiving" used only once: possible typo at 
newspro.cgi line 1576.
Name "main::newtime" used only once: possible typo at newspro.cgi line 818.
Name "main::glossaryon" used only once: possible typo at newspro.cgi 
line 745.
Name "main::JustLoadSubs" used only once: possible typo at newspro.cgi 
line 114.
Name "main::nplang_12Hour" used only once: possible typo at newspro.cgi 
line 1499.
Name "main::FormFieldsModifySize" used only once: possible typo at 
newspro.cgi line 1134.
Name "main::currenttime" used only once: possible typo at newspro.cgi 
line 817.
Name "main::npconfigversion" used only once: possible typo at 
newspro.cgi line 233.
Name "main::nplibBuild" used only once: possible typo at newspro.cgi 
line 236.
Name "main::NewsID" used only once: possible typo at newspro.cgi line 762.
Name "main::nplangversion" used only once: possible typo at newspro.cgi 
line 239.
Use of uninitialized value in pattern match (m//) at newspro.cgi line 250.
Use of uninitialized value in read at nplib.pl line 181.
Use of uninitialized value in string eq at newspro.cgi line 269.
Use of uninitialized value in string eq at newspro.cgi line 279.
Use of uninitialized value in string eq at newspro.cgi line 284.
Use of uninitialized value in string eq at newspro.cgi line 313.
Use of uninitialized value in string eq at newspro.cgi line 1277.
Use of uninitialized value in crypt at newspro.cgi line 1299.
Use of uninitialized value in crypt at newspro.cgi line 1299.
Use of uninitialized value in string ne at newspro.cgi line 1299.
Use of uninitialized value in length at newspro.cgi line 1299.
Use of uninitialized value in pattern match (m//) at newspro.cgi line 1300.
Content-type: text/html


	<html>
	<head>
	<title>NewsPro: NewsPro Login (Authorized Users Only)</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	
	<style type="text/css">
<!--
p {  font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
 .navbar {  font-family: Arial, Helvetica, sans-serif; font-size: 9pt}
 .navlink {  font-family: Arial, Helvetica, sans-serif; font-size: 9pt; 
color: #ffffff}
td {  font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
A:hover { color: #ffffff; text-decoration: none}
 .nptitle { }
 .npcontent { }
 .npfooter { }
-->
</style>
	</head><body bgcolor="#FFCC66" text="#CCCCCC" link="#FFCC33" 
vlink="#FFCC33" alink="#FFCC33">
	<div align="center">
	  <table width="60%" border="1" bordercolor="#666666" cellpadding="4" 
cellspacing="0" align="center" class="nptitle">
	    <tr bgcolor="#000099">
	      <td>
	        <div align="center"><b><font face="Verdana, Arial, Helvetica, 
sans-serif" color="#FFCC33">NewsPro Setup: NewsPro Login (Authorized 
Users Only)</font></b></div>
	      </td>
	    </tr>
	  </table>
<br>
	  <table width="90%" border="1" bordercolor="#666666" cellpadding="8" 
cellspacing="0" align="center" class="npcontent">
	    <tr bgcolor="#990000">
       <td>

		<form action="http://127.0.0.1/cgi-bin/newspro/newspro.cgi?login" 
method="post">
		<p> Username: <input type="text" name="uname"><br>
		Password: <input type="password" name="pword"></p>
		<input type="submit" name=submit value="Log In"></form>
		<br><br>To set up NewsPro, enter setup as your username and leave the 
password blank.
		</td></tr></table></body></html>
		



------------------------------

Date: Tue, 17 Apr 2001 12:03:55 +1000
From: Jill Freeman <jjfreeman@bigpond.com>
Subject: Re: svript wont run this is perl -w output help?
Message-Id: <3ADBA48B.C0FEDB46@bigpond.com>


RonB wrote:

> I cant seem to get scripts working under the cgi-bin.My testperl.pl does what it is
> supposed to do, say hello, but all my other scripts run in to the premature end of
> header....bla.

When a CGI script breaks the server will write to the error log. Have you checked the
logs?  Have you thought of using some of the CGI modules? Try using Carp:

use CGI::Carp qw(fatalsToBrowser);

if the script generates html output intended for a browser, as it obviously does, it is
necessary to add the following first line BEFORE writing any output via a bare print
statement :

          print "Content-type: text/html\n\n";

This indicates that html-code follows and the '\n\n' marks the end of header. Your script
may be trying to print something before you have printed this header, thus generating the
errror, but as you have only included a link to the script...... BTW you appear to have
 ...text/html\n\n\n, can't remember for sure but have some recollection that their is a
requirement for exactly 2 \n after the text/html -  works for me.

> this is the output with the perl -w command.

All the -w tells you is that you have a lot of variables  that are, exactly as it says,
only used once. While there are valid reasons for this typos are high on the list with
useless code a close second. The warnings are there for a purpose.

> By the way, this script works fine on my remotely hosted site.

If it works on one server but not another then a server problem is logically indicated,
however the premature end of headers error message is far more likely script related.

> Please help, any suggestion will be welcome.

Link to script?

But be warned CGI is a touchy topic in this group which prefers to focus on Perl the
language rather than problems with dysfunctional CGI scripts, especially ones that are
answered in FAQs and the numerous online resources.  There is a CGI group and if you have
a look on this group you will find numerous extended threads which start a bit like yours
and degenerate into flame wars. Doubtless there are people warming up the flame throwers
at this very moment so I expect you will soon learn the error of your wicked ways.

[snip]

Cheers

James



------------------------------

Date: Tue, 17 Apr 2001 08:12:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: svript wont run this is perl -w output help?
Message-Id: <fiundtk5km4t5qb1di28mo4k27dkom256f@4ax.com>

RonB wrote:

>Please help, any suggestion will be welcome.
>
>bash-2.04# perl -w newspro.cgi

If you're only checking the syntax from the command line, add the -c
switch. There's no reason to actually run it as well, because the
circumstances are different anyway. Start by checking the source of the
(fewer) messages you get then.

>Name "main::nplang_DateFormat" used only once: possible typo at 
>newspro.cgi line 1502.
>Name "main::SilentBuild" used only once: possible typo at newspro.cgi 
>line 970.

These probably do need fixing. Check those lines in the source. You
likely have used some variables, that don't get set anywhere. In the
source, they can look like '$SilentBuild' or '@SilentBuild' for example.

-- 
	Bart.


------------------------------

Date: Sun, 15 Apr 2001 14:22:54 -0700
From: "Arvin Portlock" <temp133@hotmail.com>
Subject: Re: Thanks, and another clue
Message-Id: <9bd3fj$rjr$1@agate.berkeley.edu>

D'oh! I removed the "|| die" from those print statements. They
were a recent addition anyway and weren't the cause of the
problem. Boy, you guys are fast!

Anyway, I tried flushing at a couple of places and got a somewhat
different approach.

foreach $log (keys %logs) {   # thus files are guaranteed unique
   open (LOG, ">$log") || die;
   print LOG $header;
   my $line;
   foreach $error (@{$errors{$log}}) {
      $line .= "$error\n";
   }

   # New addition
   my $old_fh = select(LOG);
   $| = 1;
   select($old_fh);

   print LOG $line; # This doesn't appear in the file now
   print STDERR $line; # But confirms $line has data

   # New addition
   my $old_fh = select(LOG);
   $| = 1;
   select($old_fh);

   print LOG $footer;
   close (LOG);
}

Now at least the $header information is not getting wiped out.
But $line information is not appearing in the file. I get $header
and $footer information and while $line is printed to STDERR
it's not going to the file.

I just wish I knew why it works on one Unix box but not another.

Okay, the above is actually a simplified version of the actual
code. I'm going to paste in the actual code below, but I hesitate
to do so, it's so long and I'm not sure whether that's proper to
do in this newsgroup. Also I won't paste in the entire program
because it's way to long but this code fragment may require some
context to understand, I don't know. Anyway, here goes. Anybody
spot anything?

## Open the logfile
my $logfile = $log->{file};
open (LOGFILE, ">$logfile") || die "$!\n";
## Print the header
my $datetime = &DateTime;
my $header = &LogHeader;
$header =~ s/\{DATETIME\}/$datetime/g;
$header =~ s/\{MOTD\}/$MOTD/g;
$header =~ s/\{REPOSITORY\}/$repository/g;
print LOGFILE $header;

foreach $logtype (keys %LogText) {
    if ($log->{$logtype}) {
        my $line;
        my $text = $LogText{$logtype};
        foreach $file (sort keys %{$log->{$logtype}}) {
            my $doc = $log->{$logtype}->{$file};
            my $filetitle = $doc->{filetitle};
            foreach $msg (@{$doc->{messages}}) {
                if ($Messages{$msg}->{status} eq $logtype) {
                    my $docline = $LogLine{$logtype};
                    $docline =~ s/\{FILENAME\}/$file/g;
                    $docline =~ s/\{FILETITLE\}/$filetitle/g;
                    $docline =~ s/\{MESSAGE\}/$Messages{$msg}->{text}/g;
                    $line .= $docline;
                }
            }
        }
        $text =~ s/\{TEXT\}/$line/g;
        my $old_fh = select(LOGFILE);
        $| = 1;
        select($old_fh);
        print LOGFILE $text;
    }
}
my $footer = &LogFooter;
$footer =~ s/\{DATETIME\}/$datetime/g;
$footer =~ s/\{MOTD\}/$MOTD/g;
$footer =~ s/\{REPOSITORY\}/$repository/g;
my $old_fh = select(LOGFILE);
$| = 1;
select($old_fh);
print LOGFILE $footer;
close (LOGFILE);






------------------------------

Date: Sun, 15 Apr 2001 21:48:26 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Thanks, and another clue
Message-Id: <x7itk5ltqu.fsf@home.sysarch.com>

>>>>> "AP" == Arvin Portlock <temp133@hotmail.com> writes:

  AP> D'oh! I removed the "|| die" from those print statements. They
  AP> were a recent addition anyway and weren't the cause of the
  AP> problem. Boy, you guys are fast!

  AP> Anyway, I tried flushing at a couple of places and got a somewhat
  AP> different approach.

  AP> foreach $log (keys %logs) {   # thus files are guaranteed unique
  AP>    open (LOG, ">$log") || die;

that should be 

	open (LOG, ">$log") || die "can't create '$log' $!" ;

  AP>    print LOG $header;
  AP>    my $line;
  AP>    foreach $error (@{$errors{$log}}) {
  AP>       $line .= "$error\n";
  AP>    }

  AP>    # New addition
  AP>    my $old_fh = select(LOG);
  AP>    $| = 1;
  AP>    select($old_fh);

$| is only for use with pipes, sockets and such. it makes little sense
to use it with files as they have another level of buffering in the OS. 

  AP>    print LOG $line; # This doesn't appear in the file now
  AP>    print STDERR $line; # But confirms $line has data

  AP>    # New addition
  AP>    my $old_fh = select(LOG);
  AP>    $| = 1;
  AP>    select($old_fh);

why do it again? it is set already (even though it has no real use here)

  AP>    print LOG $footer;
  AP>    close (LOG);
  AP> }

  AP> Now at least the $header information is not getting wiped out.
  AP> But $line information is not appearing in the file. I get $header
  AP> and $footer information and while $line is printed to STDERR
  AP> it's not going to the file.

  AP> I just wish I knew why it works on one Unix box but not another.

you didn't say that before. which OS's and what is the exact behavior
you are seeing that is different? is it the test script above that is
failing or the real program below? you have conditions below that may
cause $text never to be created or written.


  AP> ## Open the logfile
  AP> my $logfile = $log->{file};
  AP> open (LOGFILE, ">$logfile") || die "$!\n";
  AP> ## Print the header
  AP> my $datetime = &DateTime;
  AP> my $header = &LogHeader;

don't use &, it is so perl4.
also studly caps is ugly. perl style is lower case with _ between words.

  AP> $header =~ s/\{DATETIME\}/$datetime/g;
  AP> $header =~ s/\{MOTD\}/$MOTD/g;
  AP> $header =~ s/\{REPOSITORY\}/$repository/g;
  AP> print LOGFILE $header;

  AP> foreach $logtype (keys %LogText) {
  AP>     if ($log->{$logtype}) {

ar eyou sure this is being execute all the time?
  AP>         my $line;
  AP>         my $text = $LogText{$logtype};
  AP>         foreach $file (sort keys %{$log->{$logtype}}) {
  AP>             my $doc = $log->{$logtype}->{$file};
  AP>             my $filetitle = $doc->{filetitle};
  AP>             foreach $msg (@{$doc->{messages}}) {
  AP>                 if ($Messages{$msg}->{status} eq $logtype) {

a few comments above to clarify the log/msg structure would be useful

  AP>                     my $docline = $LogLine{$logtype};
  AP>                     $docline =~ s/\{FILENAME\}/$file/g;
  AP>                     $docline =~ s/\{FILETITLE\}/$filetitle/g;
  AP>                     $docline =~ s/\{MESSAGE\}/$Messages{$msg}->{text}/g;
  AP>                     $line .= $docline;
  AP>                 }
  AP>             }
  AP>         }
  AP>         $text =~ s/\{TEXT\}/$line/g;
  AP>         my $old_fh = select(LOGFILE);
  AP>         $| = 1;
  AP>         select($old_fh);

remove that $| as it is useless. close will flush the file fine.

  AP>         print LOGFILE $text;
  AP>     }
  AP> }
  AP> my $footer = &LogFooter;
  AP> $footer =~ s/\{DATETIME\}/$datetime/g;
  AP> $footer =~ s/\{MOTD\}/$MOTD/g;
  AP> $footer =~ s/\{REPOSITORY\}/$repository/g;
  AP> my $old_fh = select(LOGFILE);
  AP> $| = 1;
  AP> select($old_fh);

again, no need for that $| stuff.

  AP> print LOGFILE $footer;
  AP> close (LOGFILE);

on the surface, your code should print. but who knows what OS issues you
have and what is in the data structures.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


------------------------------

Date: Tue, 17 Apr 2001 11:26:06 GMT
From: "Kalle Anka" <kalle@tvettsvamp.a.se>
Subject: The return value takes no notice about the perfect match. Can I use strict, and where?
Message-Id: <iLVC6.5033$sk3.1491511@newsb.telia.net>

The form could be found at http://www.markisspecialisten.com/remove.htm

This is the list that i'm removing from: ( Could be found at
http://www.markisspecialisten.com/guestmail.htm
someone@somewere.com<br>
someone2@somewere.com<br>

This is the script that tells you that your address is removed = perfect
match, even if its not:
#!/usr/bin/perl -w

use CGI qw(:standard);

$filename = "/home/markisspecialisten/www/guestmail.htm";
$backupfile = "/home/markisspecialisten/www/backup.html";
$recipient = 'radera@markisspecialisten.com';

$q = CGI->new();
$email = $q->param( "email" ); # input from form.

print $q->header();
print $q->start_html('Resultat av kommando');
print $q->h1('Resultat av kommando');
(&cleanup);
print $q->end_html();
print "\n";


# Dont allow wildcards
sub cleanup {
  if ($email =~ tr/*?//d) {
print "Du har angivit en otillåten e-post address!<br>\n\n";
print qq {<a href="../remove.htm" target="_top">Försök igen!</a>\n} ;
} else{


    open INFILE, $filename
or return "Couldn't open file for reading";
    @infile = <INFILE>;
    close INFILE;

# Dont allow blanc inputs
if ( $email =~ /^\s*$/ ) {
print "Skriv in din e-postadress för att ta bort den från vår lista.<br>\n"
;
print qq {<a href="../remove.htm" target="_top">Försök igen!</a>\n} ;
exit ;
}

open INFILE, $filename or die "Can't open '$filename': $!";

$line;
  while (<INFILE>) {
    chomp; # drops trailing newlines; can omit if undesirable
    $line = $_, last if /^\Q$email/i && ! /^$/; # substr match!
  }

  close INFILE;
# Return "Your email address is removed."
  print "Din e-postadress fanns med i vår lista och är nu
borttagen.<br>\n\n" if defined $line;

# Return "There is no perfect match so nothing is removed"
  print "Din e-postadress fanns inte med i vår lista.<br>\n\n" unless
defined $line;
  print qq {<a href="../remove.htm" target="_top">Försök igen</a>\n} unless
defined $line;
  print " och kontrollera om det är rätt e-postadress du erhållit vår
information på.<br>\n\n" unless defined $line;
  print "Var noga med att ange små och stora bokstäver.<br><br>\n\n" unless
defined $line;
  print "Kontakta oss på " unless defined $line;
  print qq {<a href="mailto:radera@} unless defined $line;
  print qq {markisspecialisten.com">radera@} unless defined $line;
  print qq {markisspecialisten.com</a>\n} unless defined $line;
  print " om problemet kvarstår." unless defined $line;




    open BACKUP, ">$backupfile"
or return "Couldn't make backup of original file";

    if (@infile) { # Sjekk om den er tom
for $line (@infile) {
    print BACKUP $line;
}
    }

    open OUTFILE, ">$filename"
or return "Couldn't open file for writing";
for $line (@infile) {
 print OUTFILE $line unless ($line =~/^$email</);




}


   close OUTFILE;


}
}










------------------------------

Date: Tue, 17 Apr 2001 11:33:34 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: The return value takes no notice about the perfect match. Can I use strict, and where?
Message-Id: <ciaodtg7i7cms95sdh33vcjnevugqdaiu2@4ax.com>

Kalle Anka wrote:

>    $line = $_, last if /^\Q$email/i && ! /^$/; # substr match!

Perhaps you want an end anchor.

	last if /^\Q$email$/i 

-- 
	Bart.


------------------------------

Date: Tue, 17 Apr 2001 12:37:10 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: The return value takes no notice about the perfect match. Can I use strict, and where?
Message-Id: <slrn9doi3d.2h1.tjla@thislove.dyndns.org>

In article <iLVC6.5033$sk3.1491511@newsb.telia.net>,
Kalle Anka <kalle@tvettsvamp.a.se> wrote:
>The form could be found at http://www.markisspecialisten.com/remove.htm
>
>This is the list that i'm removing from: ( Could be found at
>http://www.markisspecialisten.com/guestmail.htm
>someone@somewere.com<br>
>someone2@somewere.com<br>
>
>This is the script that tells you that your address is removed = perfect
>match, even if its not:

Hmm. If you want a perfect match, I think you would be better off using
the 'eq' operator, rather than a regular expression. That way you don't
need to worry about things like wildcards. Something like (untested):

$email = param('email');

# make sure not blank
if ($email !~ m/^\s*$/)
{
    # open file as FILE
    # open backup as BACKUP
    while (<FILE>)
    {
        chomp;
        print BACKUP $_ . "\n" unless $_ eq $email;
    }
}

rename $filename $tempfile;
rename $backupfile $filename;
rename $tempfile $backupfile;

Despite the fact that I'm 1/16th swedish, I don't speak the language at
all, so I'm guessing a little about what your code does. The above is a
code fragment, so it will need some work to get it to compile.

I'd like to point out a few problems with your script. Firstly you seem
to read in the file twice which seems a little unnecessary to me. Better
I think to go with the method in the FAQ:

perldoc -q 'How do I change one line in a file'

which basically works as I've shown above.

I think the reason why your code doesn't work as you think it should is
the line:

print OUTFILE $line unless ($line =~/^$email</);

This is because here you are trying to match /^$email</ which is simply
the contents of $email followed by a '<', which makes no sense.

Additionally you do something like:

open BACKUP, ">$backupfile"
    or return "Couldn't make backup of original file";

This again makes no sense. The return value from the function this is
called from is never used. I think you meant to use die() here.

Finally, I really recommend you work on indenting your code a little
better. If you indent it a little like I have above, you will find that
related pieces of code will tend to stand out and the whole thing will
be much easier to understand.

ps. and yes, you should use 'strict'.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
There are really not many jobs that actually require a penis or a
vagina, and all other occupations should be open to everyone.
		-- Gloria Steinem


------------------------------

Date: Mon, 16 Apr 2001 16:02:17 +1000
From: "Matt Morton-Allen" <mmortonallen@csu.edu.au>
Subject: Re: Time Intervals Question
Message-Id: <BTvC6.3$G_6.778@news0.optus.net.au>

I can't believe I didn't think of that (duh!), thanks for the brain kick
start.

Matt.


"Dave Bailey" <dave@sydney.daveb.net> wrote in message
news:slrn9dknqf.l9.dave@sydney.daveb.net...
> On Mon, 16 Apr 2001 15:35:57 +1000, Matt Morton-Allen
> <mmortonallen@csu.edu.au> wrote:
> >Hi All,
> >I am looking for a way to be able to determine how many occurences of a
> >given time block occurs between two times? For example, I would like to
be
> >able to specify a block size of 30 mins, a start time of 10:AM, and a
finish
> >time of 12:00 PM and have a return value of 4 (i.e. it takes 4 30 min
blocks
> >to span the two dates). Does anyone know a way to do this?
>
> #!/usr/bin/perl -w
>
> print tmblock(10,12,30),"\n";
>
> sub tmblock{int(($_[1]-$_[0])*60/$_[2])}
>
> --
> Dave Bailey
> davidb54@yahoo.com




------------------------------

Date: 16 Apr 2001 05:51:37 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: Time Intervals Question
Message-Id: <slrn9dknqf.l9.dave@sydney.daveb.net>

On Mon, 16 Apr 2001 15:35:57 +1000, Matt Morton-Allen 
<mmortonallen@csu.edu.au> wrote:
>Hi All,
>I am looking for a way to be able to determine how many occurences of a
>given time block occurs between two times? For example, I would like to be
>able to specify a block size of 30 mins, a start time of 10:AM, and a finish
>time of 12:00 PM and have a return value of 4 (i.e. it takes 4 30 min blocks
>to span the two dates). Does anyone know a way to do this?

#!/usr/bin/perl -w

print tmblock(10,12,30),"\n";

sub tmblock{int(($_[1]-$_[0])*60/$_[2])}

--
Dave Bailey
davidb54@yahoo.com


------------------------------

Date: Mon, 16 Apr 2001 06:24:13 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Tizek.com is in dire need of a development team...
Message-Id: <x7bspxl5v6.fsf@home.sysarch.com>

>>>>> "d" == developers  <developers@tizek.com> writes:

  d> There is no pay (yet) but once we get going income will be
  d> generated through advertisements on the site and various other
  d> services which we will offer, and there will surely be enough to go
  d> around.  Brief Overview:

sure. i will donate all my time to you for promises of plenty of stock
options!

  d> TizEK.com is destined to be THE premiere Internet portal for techies and
  d> geeks alike. We currently need graphic developers, HTML authors, PHP,
  d> CGI/PERL authors, and creative minds. To apply, mail us at
  d> developers@tizek.com

wow! a portal that will actually make money!! i bet your business plan
has found the secrets of profitability that none of the others
have. build it and they will browse (and BUY!). i AM impressed. sign me
up immediately!! i can work for 2 years with no pay. i love to sacrifice
my life and family for such high risk ventures. well, yours isn't so
high risk as you discovered the gold mine hidden in the net.

thanx,

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


------------------------------

Date: Thu, 19 Apr 2001 12:36:22 +0200
From: Martin Bower <Martin.Bower@ib.bankgesellschaft.de>
Subject: using SYSTEM to run progs
Message-Id: <3ADEBFA6.5139DFE0@ib.bankgesellschaft.de>

I`m currently running a daemon to check whether files have been created
in a directory, then running another perl program if they have,
using....

   my @args = ("perl", "test.pl", $dateiname, "A string", "market",
"other", "M");
   system(@args) == 0 or die "system @args failed: $?";

is this effecient, or should I be using a different way to shell out
programs ?



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 718
**************************************


home help back first fref pref prev next nref lref last post