[8235] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1852 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 10 20:15:09 1998

Date: Tue, 10 Feb 98 17:00:31 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 10 Feb 1998     Volume: 8 Number: 1852

Today's topics:
    Re: 50MB - 200MB FREE WEBSPACE! CGI PROGRAMMER NEEDED (Martien Verbruggen)
    Re: ? Regular Expressions ? <tchrist@mox.perl.com>
    Re: [perl] accept a char at a time without.. <tchrist@mox.perl.com>
    Re: array question (O'Shaughnessy Evans)
    Re: array question (Craig Berry)
    Re: array question <tchrist@mox.perl.com>
    Re: array question (O'Shaughnessy Evans)
        Delays of less than a second? <pholfelder@btg.com>
    Re: Delays of less than a second? <tchrist@mox.perl.com>
    Re: Happy with Perl? (from root account)
    Re: Hashes Usage (Steve Linberg)
        How to "override" modules with -MModule ? (Bryan Bayerdorffer @ Wit's End)
    Re: How to search for control characters ... <tchrist@mox.perl.com>
    Re: Huge arrays: 'Out of Memory' (Malcolm Hoar)
    Re: I have a glob prob (Craig Berry)
    Re: I have a glob prob <ebohlman@netcom.com>
    Re: m/pattern/o  --  when to use? <tchrist@mox.perl.com>
    Re: Math Floor and Ceiling Function <tchrist@mox.perl.com>
    Re: Monitoring a file <tchrist@mox.perl.com>
    Re: multi-line regexp help needed <tchrist@mox.perl.com>
        output_autoflush and fork problem in perl <pbanks@ix.netcom.com>
    Re: perl form problem <rootbeer@teleport.com>
    Re: Perl lessons Hong Kong (Steve Linberg)
    Re: perl5.003 and now CGI won't work (Jeff Yoak)
    Re: Please, help - rsh problem. <tchrist@mox.perl.com>
        polyform error <admin@mail.y-net.com.au>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 10 Feb 1998 22:16:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: 50MB - 200MB FREE WEBSPACE! CGI PROGRAMMER NEEDED
Message-Id: <6bqjk3$q0g$1@comdyn.comdyn.com.au>

[CC to poster, to both addresses]

Brian Hancock <whs010@conrad.appstate.edu> writes:

> My partner and I are in desperate need of a very experienced and very
> profesional CGI Programer.  You would be the main CGI Programmer for our
> sites and get 100mb - 200mb of free web space as pay.  You must be willing
> to work for free.  We are getting 2-5 new sites soon and will need a very
> very good cgi programmer for our sites.  Thank You.
> Preferably a programer that also knows how to make cgi databases and keep
> them up.  PLEASE RESPOND BY E-MAIL IF YOU ARE INTERESTED AT ALL!!  DO NOT
> RESPOND IN THE NEWSGROUP.

A few points:

- I doubt very much that you will ever get any 'very experienced' and
  'very professional;' CGI programmer to work for free for you.
  They're all working on other things which pay. The 'lure' of a cheap
  few MB of web space is hardly enough.

- This post is inappropriate to this group. This is _not_ a CGI group,
  but a Perl group. That aside, job advertisements don't belong in
  groups about the language.

- I don't think that you people could handle a professional programmer
  of any kind. Your post is highly unprofessional, and even includes
  spelling mistakes. It's badly formatted. You continue the letter
  after you close it with a "Thank You.".

- You probably shouldn't even think of being in this business if you
  cannot even grasp a few fundamental rules of netiquette. You post
  inappropriately, you use excessive capitalisation, even in the
  subject line, you advocate responses by email only, you have a From:
  address which is different from the email address you want the
  response to go to.

- You obviously have no clue what you're talking about: You post a job
  advertisement for a CGI programmer to a perl group, and you talk
  about CGI databases, whatever they would be. Phrases like 'make cgi
  databases and keep them up' hardly sound like the writer has any
  clue what he or she is talking about.

You have found yourselves a place in my killfile, and doubtless in
many other people's killfiles. Most likely most of these people are
exactly the ones that you were trying to reach.

Not smart.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Advertising:  The science of arresting
Commercial Dynamics Pty. Ltd.       | the human intelligence long enough to
NSW, Australia                      | get money from it.


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

Date: 10 Feb 1998 23:59:22 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: ? Regular Expressions ?
Message-Id: <6bqpkq$l7c$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, "Peter Perchansky" <fp@pmpcs.com> writes:
:I have a string that may contain one or more comma delimited email
:addresses.  I only want to add an email address to this list if the alias
:portion of the email address is not already within the list.

Whenever you hear the word "in" or "within", particularly
when used in conjunction with a "list" or an "array",  Pavloving
bells should set to ringing: *HASH* is what you're looking for.

Actually, the FAQ is what you're looking for.  It covers this
quite handily.

    % man perlfaq4
      ...
      How can I tell whether an array contains a certain element?

:What I've tried:
:
:    $_ = $receiverlist;
:    if (!(/($singlereceiver)/)) ## if receiver isn't already in list

No.  No no no.  Don't use pattern matches when you mean a string
search.  Don't interpolate strings into patterns unless you cannot
possibly hope to avoid it.

    % man perlfaq6
      ...
      How do I efficiently match many regular expressions at once?

Anyway, you're barking up something of the wrong tree here.  I cannot
begin to convey to you the supernova effect from the enlightenment you
will receive if you but once read through in their entirety (please;
please please please please please) the manpages and most especially
the faqs, both readily available with every current perl distribution.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    X-Windows: Foiled again.
	--Jamie Zawinski


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

Date: 11 Feb 1998 00:33:46 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: [perl] accept a char at a time without..
Message-Id: <6bqrla$l7c$9@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, wakaranai <khoohuit@iscs.nus.edu.sg> writes:
:	how do i accept a char input without having to press the
:	enter key in perl?

Precisely as the FAQ demonstrates.

    % man perlfaq8
    How do I get one key from the terminal at a time, under POSIX?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
I believe in the waterbed theory of linguistics.
If you push down here, it pops up there.
        -- <1993Jan20.181244.8680@netlabs.com>


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

Date: 10 Feb 1998 22:51:57 GMT
From: shaug@callamer.com (O'Shaughnessy Evans)
Subject: Re: array question
Message-Id: <6bqlmd$ddn$1@ha1.rdc1.occa.home.com>

In article <6bo7an$q5$3@csnews.cs.colorado.edu>,
	Tom Christiansen <tchrist@mox.perl.com> writes:
> Dave Barnett <barnett@houston.Geco-Prakla.slb.com> writes:
>:How about @array = ();   ?
>:That should empty @array.
>:@array = undef; also works
> 
> God's Teeth, man, *what* are you talking about!?  The latter
> doesn't work at all!  Test it.  Learn.

Hmm... from reading the camel book, it looks like ``@array = undef'',
or more precisely, ``undef @array'' (p. 235), should work to remove
the elements of an array.  Testing this seems to work as well:

  % perl -we '@a=qw(a b c); print "a: @a\n"; @a=undef; print "a: @a\n";'
  a: a b c
  Use of uninitialized value at -e line 1.
  a: 

  % perl -we '@a=qw(a b c); print "a: @a\n"; @a=(); print "a: @a\n";'
  a: a b c
  a: 

So, Tom, are you saying that it does more than that as well?  That is,
``@array = undef'' will deallocate all storage associated with @array,
and even remove the definition of @array itself, while ``@array = ()''
will just remove the elements, but leave @array defined?

Thanks :)

-- 
 O'Shaughnessy Evans
 http://www.callamerica.net/shaug/


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

Date: 10 Feb 1998 23:24:32 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: array question
Message-Id: <6bqnjg$he5$7@marina.cinenet.net>

O'Shaughnessy Evans (shaug@callamer.com) wrote:
: Hmm... from reading the camel book, it looks like ``@array = undef'',
: or more precisely, ``undef @array'' (p. 235), should work to remove
: the elements of an array.

'undef @array' and '@array = undef' mean very different things.  'undef 
@array' means 'make @array undefined'; it will have (effectively) zero 
elements.  '@array = undef' follows the rule for assigning a scalar to an 
array; it's equivalent to '@array = ( undef )', and the resulting array 
has 1 element.

  perl -e "undef @a;   print 0 + @a;"       -> 0
  perl -e "@a = undef; print 0 + @a;"       -> 1

: Testing this seems to work as well:
: 
:   % perl -we '@a=qw(a b c); print "a: @a\n"; @a=undef; print "a: @a\n";'
:   a: a b c
:   Use of uninitialized value at -e line 1.
:   a: 
: 
:   % perl -we '@a=qw(a b c); print "a: @a\n"; @a=(); print "a: @a\n";'
:   a: a b c
:   a: 

As undef interpolates as a zero-width string, this doesn't prove much.

: So, Tom, are you saying that it does more than that as well?  That is,
: ``@array = undef'' will deallocate all storage associated with @array,
: and even remove the definition of @array itself, while ``@array = ()''
: will just remove the elements, but leave @array defined?

Here's the rundown:

@a = undef     Makes @a a single element list, that one element being
               the undef value.  You almost never want to do this.

@a = ()        Makes @a a zero element list.

undef @a       Makes @a undefined.  Given the way Perl variables spring
               into existence as needed, this is equivalent for most
               practical purposes to '@a = ()'.  The only ways to tell
               the difference are warnings about undefined values being
               used or explicit use of 'defined @a'.

Hope this helps!

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 10 Feb 1998 23:51:13 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: array question
Message-Id: <6bqp5h$l7c$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, shaug@callamer.com (O'Shaughnessy Evans) writes:
:Hmm... from reading the camel book, it looks like ``@array = undef'',
:or more precisely, ``undef @array'' (p. 235), should work to remove
:the elements of an array.  

undef(@array) is nothing whatsover like assigning to an array 
a list containing one single undefined element.  Nothing.  
You cannot find that in the Camel.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    That means I'll have to use $ans to suppress newlines now.  
    Life is ridiculous. 
        --Larry Wall in Configure from the perl distribution


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

Date: 11 Feb 1998 00:27:42 GMT
From: shaug@callamer.com (O'Shaughnessy Evans)
Subject: Re: array question
Message-Id: <6bqr9u$8uu$1@ha1.rdc1.occa.home.com>

[courtesy cc of this posting sent to cited author via email]

In article <6bqp5h$l7c$1@csnews.cs.colorado.edu>,
	Tom Christiansen <tchrist@mox.perl.com> writes:
> 
> In comp.lang.perl.misc, shaug@callamer.com (O'Shaughnessy Evans) writes:
>:Hmm... from reading the camel book, it looks like ``@array = undef'',
>:or more precisely, ``undef @array'' (p. 235), should work to remove
>:the elements of an array.  
> 
> undef(@array) is nothing whatsover like assigning to an array 
> a list containing one single undefined element.  Nothing.  
> You cannot find that in the Camel.

:-)  Technically, I don't believe that I said it was there:  "more
precisely, ``undef @array''."  But I did equate the two, which is
effectively the same, I suppose.  If I understand what Tom's saying
now, the mistake I made was equating undef()'s action with undef()'s
return value.  So, then, I now have a question; would someone please
confirm whether I have these right?

    @array = undef;     # @array is now of length one, with a single
                        # undefined value.  This was the key of my
                        # mistake.
    
    undef @array;       # @array no longer exists in the symbol table,
                        # and is therefore not defined.  All memory
                        # that was associated with it has effectively
                        # been released.

    @array = ();        # @array is now of length zero.

    $#array = -1;       # @array is now of length zero.  See PP, p49.

Thanks :-)  And yes, I did look in the perlfaqs and the Camel book
to research this stuff before making this post.  I'm just trying to
confirm my interpretation of what I read in perlfaq4, perlfaq7, and
the Camel index entries for 'undef' and 'array'.

-- 
 O'Shaughnessy Evans
 http://www.callamerica.net/shaug/


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

Date: Tue, 10 Feb 1998 18:23:18 -0500
From: Peter Holfelder <pholfelder@btg.com>
Subject: Delays of less than a second?
Message-Id: <34E0E165.DD8F269E@btg.com>

Is there a way I can set a delay of less than one second? I'm using
sleep now, but I really shouldn't be delaying for a second or more...

Thanks,
Peter Holfelder
pholfelder@btg.com



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

Date: 11 Feb 1998 00:12:32 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Delays of less than a second?
Message-Id: <6bqqdg$l7c$4@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Peter Holfelder <pholfelder@btg.com> writes
while using the forbidden "X-Mailer: Mozilla 4.0 [en] (WinNT; I)":

:Is there a way I can set a delay of less than one second? I'm using
:sleep now, but I really shouldn't be delaying for a second or more...

Probably not.  

    % man perlfaq8
    ...
    How can I sleep() or alarm() for under a second?

    % man perlfunc
    ...
    alarm   Arranges to have a SIGALRM delivered to this process after
    ...
	    For delays of finer granularity than one second, you may use
    ...
    sleep   Causes the script to sleep for EXPR seconds, or forever if no
    ...
	    For delays of finer granularity than one second, you may use

That's about twenty of those in the last couple of hours.  I suggest
that we start a new newsgroup called

    comp.lang.perl.i'm-from-microsoft-so-won't-read-documentation

Seriously, the net helps those who help themselves.  Read manpages,
or don't post.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "Hey, I like C too, and have written uglier programs than that." --Larry Wall


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

Date: Tue, 10 Feb 1998 18:07:50 -0500
From: "John Chambers (from root account)" <jc@eddie.mit.edu>
Subject: Re: Happy with Perl?
Message-Id: <34E0DDC6.FF6@eddie.mit.edu>

Mark Lewis wrote:
> 
> I am looking into the possibility of rewriting all the site-specific shell
> scripts for our company in perl, but am checking to see if anybody else
> has done this and wished they hadn't.

It's not only possible, but often desirable.  But you should approach it
on a script-at-a-time basis.  If a shell script is doing the job to your
satisfaction, why waste time rewriting it?  On the other hand, if you
have any complaints about a script, once you're familiar with perl, you
may well want to do a rewrite as a first step.  Among other things, a
shell script translated to perl will often run much, much faster, and
won't leave around all those scratch files to be cleaned up.  And it'll
be a much lighter load on your machine, because you don't have to do
silly things like forking a subprocess to do arithmetic.  But if all
your
scripts are little 3-liners, don't bother.

What you will find is that, once your programmers are familiar with
perl,
it won't take long before there are no new shell scripts being written.
They'll all be in perl.  This has happened in many companies, whose
management is suddenly startled to find that half their software is
written in this language that they've never heard of or approved ...

> can somebody send me a list of other perl newsgroups to send this message to.

No.  This is the best one.

> is perl stable?  would it be a good idea to risk millions of pounds on
> something that is unsupported?  what do you think?

I'll leave it to others to flame you royally for that question.  

In my experience, perl is probably *the* mostly stable and
reliable programming language around.  I've gone through a
great many upgrades, and I've *never* had a perl script break
with a new release.  I can't say this for any other language
that I've ever used.  Even the big change to perl5 didn't break
anything at all.  I was impressed.

As for support, well, how much "support" do you get for the shells?

(And there are some companies that sell consulting and support for
perl.  This has come about because of the importance of perl to the
web and the need for companies to have web sites with scripts behind
the web pages.  But there isn't much support ever needed, other than
the occasional upgrade when you want to use a module that requires
a later perl than what you have.)


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

Date: Tue, 10 Feb 1998 19:20:48 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Hashes Usage
Message-Id: <linberg-1002981920480001@projdirc.literacy.upenn.edu>

In article <34E0D173.B1BB054C@micro.ti.comSNIP>, Holly Sommer
<SNIPhsommer@micro.ti.comSNIP> wrote:

> In looking through the blue camel book, pages 270 - 271 seem to delve
> into this matter. However, the examples given operate in examples where
> the data being stuck into the hashes is known ahead of time, and I'm 
> dealing with a dynamically-changing dB, so it's a little bit different.

Well, just use the same structures, but substitute your variables for the
constants in the examples, right?  So instead of:

%Hoh = (
   flintstones => {
      lead     => "fred",
      pal      => "barney",
}

You would write

%Hoh = (
   flintstones => {
      lead     => $something,
      pal      => $somethingelse,
}

The question is, do you really want a hash-of-hash structure?  If your
records are of a regular structure, you probably want an array-of-hash
structure, which is explained on p. 268-9.  I use these a lot when dealing
with SQL databases.

I doubt anyone can give a clearer explanation of these data structures
than you'll find in the book.  Type the examples in yourself and play with
them.  You'll get it.

-- 
Steve Linberg                  |    National Center on Adult Literacy
Systems Programmer etc.        |           University of Pennsylvania
linberg@literacy.upenn.edu     |        http://www.literacyonline.org


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

Date: 11 Feb 1998 00:08:43 GMT
From: bryan@spd.analog.com (Bryan Bayerdorffer @ Wit's End)
Subject: How to "override" modules with -MModule ?
Message-Id: <6bqq6b$ec3@nwd2nws1.analog.com>


Ok, "override" isn't the right word, but I was trying to keep the subject line
short.

I have a skeleton Perl program, written as a set of modules/files, say A.pl,
B.pm, C.pm.  Now, I want other folks to be able to replace C.pm with their own
modules (say X.pm and Y.pm) WITHOUT having to modify A.pl or B.pm.  The only
thing they should have to worry about is that X and Y export the same
symbols that C exports.

The difficulty I have is that module names are file names, and I don't want to
restrict the names or even the number of files that will be used.  Now, for the
main package, A.pl, there's no problem.  The new modules can be specified on
the command line:

perl -MX -MY -- A.pl ...

and perl sticks an implicit 'use X; use Y;' in A.  However, code in B.pm also
needs to see the symbols exported by X and Y.  Even though A contains 'use B;'
B doesn't get the implicit 'use X; use Y;' when it is compiled, which is
probably as it should be.  

The question is, how can code in B refer to symbols exported by X and Y, when
the names X and Y are not fixed?

I've thought of using the C preprocessor and a wrapper script.  The wrapper
would get the module names (e.g. X and Y) from the command line, then write the
include file /tmp/something_unique containing

use X;
use Y;

and then just invoke

perl -P A.pl

B would contain

#include "/tmp/something_unique"


This of course is uglee in the extreme.  Any better ways to do this?  Will a
runtime thing like this work?

require $module;
$module->import();


--
 .. ..-. ..- -.-. .- -. .-. . .- -.. - .... .. ... --. . - .- .-.. .. ..-. . !!
Bryan Bayerdorffer         bryan@outer.net                bryan@spd.analog.com
                   (Wit's End Computation Center)           (Analog Devices)
+1 512-427-1063  +1 512-427-1059 (fax)     Bar code: || | |||| || | ||  || ||||


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

Date: 11 Feb 1998 00:20:05 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to search for control characters ...
Message-Id: <6bqqrl$l7c$7@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Eric Bohlman <ebohlman@netcom.com> writes:
:Rajiv Shivane <shiva001@tc.umn.edu> wrote:
:
:: I am a new perl user and I managed to go through the ``learning perl''
:: book but I am not able to search for control characters. I want to
:: search and replace all the control M (^M) characters in $_ with <BR>\n.
:: I tried s/^./<BR>\n/g; but it didn't work.
:
:Of course it didn't.  That says to replace the first character on the 
:line with "<BR>\n" and then to try to repeat it (which will always fail, 
:because you have only one line in $_.
:
:Try s/\r/<BR>\n/g;

It is extremely unlikely that there will be a carriage return
present.  \cM turns into \n, or nothing, on input.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "Just because you're into control doesn't mean you're in control."
    	--Larry Wall


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

Date: Tue, 10 Feb 1998 22:59:47 GMT
From: malch@malch.com (Malcolm Hoar)
Subject: Re: Huge arrays: 'Out of Memory'
Message-Id: <6bqm54$9qc$3@nntp1.ba.best.com>

In article <6bqie5$23v$2@csnews.cs.colorado.edu>, tchrist@mox.perl.com (Tom Christiansen) wrote:

>You might investigate the $^M variable in recent releases, but I really
>would not count on it. 

May I ask why?

I've considered this (not to solve the problem of infinite
virtual memory) but to be able to report *which* system/memory
limit caused the "Out of Memory" condition in the first place.

It would be cool if Perl and the Perl malloc() would do this by
default. I can see that might be hard (impossible?) if Perl was
built with the native OS malloc().

-- 
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Malcolm Hoar           "The more I practice, the luckier I get". |
| malch@malch.com                                     Gary Player. |
| http://www.malch.com/               Shpx gur PQN.                |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 10 Feb 1998 23:33:53 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: I have a glob prob
Message-Id: <6bqo51$he5$8@marina.cinenet.net>

Steve Walker (steve@undergroundshopper.com) wrote:
: I have never used glob before, but need to generate a web page based on
: the existence of certain files in a certain directory.

Let me guess...on an NT server, right?

: Here is basically what I have (removing the gory details) in my cgi:
[snip]
: $counter_dir = "./Counter";
[snip]
: Here is the source of the page generated by this cgi:
[snip: Files not there]
 : There *are* files of the form count_* in the directory. If I run this
: program from the shell, it outputs as expected, giving the file names
: that match in that directory.

The key words above are 'the directory'.  Which directory?  NT servers 
are (in)famous for setting . to some dir other than the one from which 
your script is being run.  Either do a chdir to the right dir at the top 
of your script, or use only absolute paths in filenames.

HTH...

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 11 Feb 1998 00:07:11 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: I have a glob prob
Message-Id: <ebohlmanEo6tnz.D9@netcom.com>

Steve Walker <steve@undergroundshopper.com> wrote:

: I have never used glob before, but need to generate a web page based on
: the existence of certain files in a certain directory.

: Here is basically what I have (removing the gory details) in my cgi:
                                                                  ^^^
The fact that this is a CGI script is an important detail here.  Why?

: #!/usr/local/bin/perl
: print "Content-type: text/html\n\n";
: print qq!<HTML><HEAD></HEAD><BODY>!;
: $counter_dir = "./Counter";

Because "." probably doesn't mean what you think it does here.  It refers 
to the current working directory that your HTTP server uses when it 
executes a CGI script.  This is probably *not* the same CWD you have when 
you run the script from your shell account.

: while (glob ("$counter_dir/count_*"))

In fact, it certainly isn't, because you say below that you do have files 
matching the pattern, and this loop is going to run forever if your glob 
returns a non-empty result.  I think you want "foreach" here, not "while."

: {
:     print $_;
: }
: print qq!</BODY></HTML>!;
: # End of cgi

Since this is a CGI script, and therefore needs to run quickly to avoid
loading down the server, I'd avoid using glob because it has to start 
up a separate process in order to gather its results.  I'd use opendir and
readdir, along with a regular-expression match, instead. 



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

Date: 11 Feb 1998 00:43:32 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: m/pattern/o  --  when to use?
Message-Id: <6bqs7k$l7c$13@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, using a forged address now revealed for all the
world to sift, tshinnic@io.com (Thomas L. Shinnick) writes:

:Does this mean that /o is useful _only_ when the pattern contains 
:interpolated variables?  

Yes, and only those that don't change.

:Thus m/RTFM/o is a waste of typing?

Yes.

You'll find that perlfaq6 talks about this somewhat,
as does the book ``Mastering Regular Expressions''.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    #else /* !STDSTDIO */     /* The big, slow, and stupid way */
        --Larry Wall in str.c from the 4.0 perl source code


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

Date: 11 Feb 1998 00:44:44 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Math Floor and Ceiling Function
Message-Id: <6bqs9s$t5t$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    David E Newman <denewman@cs.buffalo.edu> writes:
:I was wondering if there was a Perl supports the 
:math function floor and ceiling. 

I was wondering whether you'd consulted the manpages.
In fact, perlfaq4 answers this very question.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "You can only measure the size of your head from the inside." --Larry Wall


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

Date: 11 Feb 1998 00:35:23 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Monitoring a file
Message-Id: <6bqrob$l7c$10@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, using the forbidden Mozilla 3.01 (WinNT; I),
Anthony Licciardi <anthonyl@kodak.com> writes:

:Has anyone written or know of a simple way to monitor a file, sleep for
:a few seconds and then check to see if the file has increased in length
:and if so, to read the newly added lines and pipe them into another
:file????!??

Yes.  Many people.  

    % man perlfaq5
    ...
    How do I do a tail -f in perl?

Being a victim of the Evil One is not a legitimate excuse for ignorance
of the FAQ.

--tom


-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    "You can't have filenames longer than 14 chars.  
     You can't even think about them!"
        --Larry Wall in Configure from the perl distribution


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

Date: 11 Feb 1998 00:18:08 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: multi-line regexp help needed
Message-Id: <6bqqo0$l7c$6@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, using Mozilla 2.02 (Macintosh; I; PPC),
blairhj@intnet.net writes:

:Help !  I'm a perl newbie so this could make or break my perl career.
:I'm trying to extract multi-line block of text from a very large file.
:I can specify the begin pattern and the end pattern. The variation is a
:string in the middle.
:Any help will be greatly appreciated.

    % man perlfaq6
    ...
    How can I pull out lines between two patterns that are themselves on
    different lines?

    You can use Perl's somewhat exotic .. operator (documented in the
    perlop manpage):

           perl -ne 'print if /START/ .. /END/' file1 file2 ...

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
        "Anyone who is capable of getting themselves made President,
         should, on no account, be allowed to do the job."
         --Douglas Adams, _The Restaurant at the End of the Universe_


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

Date: Tue, 10 Feb 1998 15:23:22 -0800
From: Paul Banks <pbanks@ix.netcom.com>
Subject: output_autoflush and fork problem in perl
Message-Id: <34E0E16A.58692B60@ix.netcom.com>

I have a perl script that forks a couple of children.
Each child starts a unix command such as vmstat and writes the output to
an output file for later analysis.  At least that is the plan.

I can get the output written to one file by using the $|
(output_autoflush) feature.  I have dug into this feature enough to find
out about FileHandle, and even tried that.

My problem is I can write the output from one child, but not the other.
I know the logic is ok because if I comment out the fork for one child,
the other child writes the output just fine.

I would expect each child to run separately and write their output to
the respective files.  Obviously I don't understand perl or what is
happening.

Any help or suggestions would be appreciated.

Paul Banks
pbanks@ix.netcom.com





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

Date: Tue, 10 Feb 1998 16:28:26 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Brian Charles <charlesb@ccmail.orst.edu>
Subject: Re: perl form problem
Message-Id: <Pine.GSO.3.96.980210162714.29818F-100000@user2.teleport.com>

On Tue, 10 Feb 1998, Brian Charles wrote:

> The first part of the program isn't working. Data isn't being appended
> into the 'database' file from the form,

> #!/usr/bin/perl

If it's not working right, try using -w to see why it's not working. (To
be sure, you should develop with -w on in the first place.)

> require "cgi-lib.pl";

You should almost certainly use 'use CGI' instead.

> #open the guestbook file and append data to the end of it
>         open FILE,"database" or die "Cannot open database: $!";
>           #print the information
>           print FILE "$in{'lastname'}, $in{'firstname'}|$in{'email'}\n";

That's where -w will catch your error. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 10 Feb 1998 19:12:49 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Perl lessons Hong Kong
Message-Id: <linberg-1002981912490001@projdirc.literacy.upenn.edu>

In article <34E02DFE.28DB@noemail.com>, noemail@noemail.com wrote:

> I would like to take private lessons in Perl and C programming (advanced
> programming - I know the basics).  I am situated in Hong Kong.
> 
> If anyone can provide this service please email me a fee proposal.  

And how should one do this, noemail@noemail.com?

What tremendous restraint I am using at the moment!  I'll bet others
aren't so kind in their responses.  Get your asbestos suit out.

-- 
Steve Linberg                  |    National Center on Adult Literacy
Systems Programmer etc.        |           University of Pennsylvania
linberg@literacy.upenn.edu     |        http://www.literacyonline.org


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

Date: Tue, 10 Feb 1998 23:39:36 GMT
From: jeff@yoak.com (Jeff Yoak)
Subject: Re: perl5.003 and now CGI won't work
Message-Id: <6bqor1$p2a@dfw-ixnews6.ix.netcom.com>

Rod Bush <rbush@mail.dac.net> wrote:

>I just installed the latest version of wwwstat on my Linux based Apache
>web server. An upgrade to perl5.003 came with it. Now none of my cgi
>scripts are working. Needless to say my customers are hot.
>I was running perl5.001 and all was well. Can anybody help with
>suggestions before I crawl back down in the pit?
>Seems like going back to the perl5.001 would be the easiest solution but
>I'm not sure how to uninstall the perl5.003.  Why? because I didn't
>realise that I was installing perl5.003 till it was done. After
>configuring wwwstat, I ran the makeall for it and it "upgraded" my
>perl5.001 to 5.003. Hope somebody can help with advise.

Why not install the now-current version of Perl and make sure that it
is installed correctly rather than try to work backwards?

Cheers,
Jeff

-------------------------------
Jeff Yoak         jeff@yoak.com



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

Date: 11 Feb 1998 00:25:28 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Please, help - rsh problem.
Message-Id: <6bqr5o$l7c$8@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, ekogan@mindspring.com writes:
:Please, anyone! Any help would be greatly appreciated! 
:I am having a problem with rsh. 

Then this is not a perl problem.

:The problem is that while the whole
:process is done without any problems, the rsh never returns, it just
:hangs even after the proxy is restarted. 

Classic file descriptor leak:  your forked child didn't close the remote
connections over the socket.  See the Unix FAQ:

3.2)  How do I use "rsh" without having the rsh hang around until the
      remote command has completed?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    That means I'll have to use $ans to suppress newlines now.  
    Life is ridiculous. 
        --Larry Wall in Configure from the perl distribution


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

Date: Wed, 11 Feb 1998 11:50:24 +1100
From: admin <admin@mail.y-net.com.au>
Subject: polyform error
Message-Id: <34E0F5D0.7D2A@mail.y-net.com.au>

Hi,

I have a nt4 operating system and option pack 4.I loaded polyform into
my inetpub/scripts file.The problem I am having is that every time I
tried to submite an application an error 500,documents contians no data
or  HTTP Error 405

405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource
identified by the request.
Please ensure that you have the proper MIME type set up for the resource
you are requesting.

Please contact the server's administrator if this problem persists.


Please advice.


Thanks

Joseph


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1852
**************************************

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