[7726] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1352 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 21 05:07:26 1997

Date: Fri, 21 Nov 97 02:00:30 -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           Fri, 21 Nov 1997     Volume: 8 Number: 1352

Today's topics:
     Re: 5.004_01 bug? (Vladimir Sovetov)
     Re: 5.004_01 bug? (Ilya Zakharevich)
     Re: ^D not working (Eric Bohlman)
     Re: Chmod a file within a perl script! (BEN GILBERT)
     DBM-speed <mortensi@idt.ntnu.no>
     Re: Error 2009, a hard one to solve (Tad McClellan)
     Error when closing database connection <techno@pedal.se>
     Re: File test operators do not work as advertised!! (Eric Bohlman)
     Re: Finding the longest common prefix over a list of st (Ilya Zakharevich)
     Re: giving up on flock (Eric Bohlman)
     How Do I delete a file? <stanier@neuma.com>
     Re: How Do I delete a file? <stanier@neuma.com>
     Re: is it possible to reference a sub-array? <lauef@pacific.net.sg>
     Re: is it possible to reference a sub-array? <markm@nortel.ca>
     Re: is it possible to reference a sub-array? (Bart Lateur)
     New to perl.   What's wrong with this script? <jz32@cornell.edu>
     open, seek and monitoring email <andrewe@technologyXchange.com>
     Re: Perl 5's glob() function (Eric Bohlman)
     Re: Perl 5's glob() function (Xyvind Gjerstad)
     Perl Enhancement (was: Re: Last element of an anonymous <markm@nortel.ca>
     Re: Perl for NT Bug ? (Eric Bohlman)
     Re: Perl for NT Bug ? <Steve_Kilbane@cegelecproj.co.uk>
     Re: Problem with localtime and timelocal (getting the W <Patrick.Hayes.CAP_SESA@renault.fr>
     Re: Problem with localtime and timelocal (getting the W <b.leguen@renault.fr>
     Re: Rename Ref file (Eric Bohlman)
     Re: Safe use of flock() -- was Re: giving up on flock <markm@nortel.ca>
     Sorting an array <ycueff@club-internet.fr>
     Suppressing echo at STDIN <kscott@pcisys.net>
     text stripping (BEN GILBERT)
     Re: Year2000 problem with localtime(); (Martien Verbruggen)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 21 Nov 1997 05:02:45 GMT
From: sova@kpbank.ru (Vladimir Sovetov)
Subject: Re: 5.004_01 bug?
Message-Id: <6534ll$djr$1@home.kpbank.ru>

Vladimir Sovetov (sova@kpbank.ru) wrote:
: This is the FAQ's idea for HTML tags removing

:     #!/usr/bin/perl -p0777
:     s/<(?:[^>'"]*|(['"]).*?\1)*>//gs

: This is the test script

: %cat ts
: #!/usr/bin/perl -p0777
:     s/<(?:[^>'"]*|(['"]).*?\1)*>//gs

: %cat index.html|./ts
: /<(?:[^>'"]*|(['"]).*?\1)*>/: ?+* follows nothing in regexp at ./ts line 2.
   
    Well, after a bit of playing with it I decided eventualy that
  it's not a bug, our dear Perl just became smarter. 
    Yeah!-)) Now this is 
    s/<(.*)*>//gs
 an error.

   So I'd suggest such simple and innocent FAQ idea correction.
     s/<(?:[^>'"]+|(['"]).+?\1)*>//gs

---
Vladimir Sovetov | Kuzbassprombank


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

Date: 21 Nov 1997 05:24:58 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: 5.004_01 bug?
Message-Id: <6535va$85o$1@agate.berkeley.edu>

In article <6534ll$djr$1@home.kpbank.ru>,
Vladimir Sovetov <sova@kpbank.ru> wrote:
>     Well, after a bit of playing with it I decided eventualy that
>   it's not a bug, our dear Perl just became smarter. 
>     Yeah!-)) Now this is 
>     s/<(.*)*>//gs
>  an error.

This bug/feature is going to demolished soon (for some value of soon,
sigh!). 

Ilya


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

Date: Fri, 21 Nov 1997 00:10:04 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: ^D not working
Message-Id: <ebohlmanEJyz4s.3uy@netcom.com>

brian d foy (comdog@computerdog.com) wrote:
: In article <652a63$9mi$1@gamera.albany.net>, "Skip Egley" <egley@albany.net> wrote:

: >@array = <STDIN>;
: >
: >and perl will keep stuffing array with lines from standard input until a ^D
: >(Control-D). Mine doesn't work. The ^D simply prints a weird character on
: >the screen. It doesn't interrupt the receiving of data from standard input.
: >Am I doing this right? Is there something wrong with my version of perl? I
: >downloaded the latest one for Win95, I believe it was 5.004_02.

: ^D is a Unix sort of thing.  perhaps that other OS has a different key?  how
: do you normally signal the end of input?

On Win95, it's ^Z (which usually needs to be followed by a CR).



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

Date: 21 Nov 1997 07:05:59 GMT
From: beg1@axe.humboldt.edu (BEN GILBERT)
Subject: Re: Chmod a file within a perl script!
Message-Id: <beg1-2011972312080001@sdn-ts-002caeurep04.dialsprint.net>

In article <3474F92B.DE0EF898@golden.net>, The Tufgars <tufgar@golden.net>
wrote:

> I'm trying to Make a file that is inaccessible to anyone browsing the
> web accessible, when the run my script.  I was thinking of somehow
> locking the file with chmod and then unlocking it when a user wanted
> it.  Then lock it back up when they were done.  Is this possible?  or is
> there and easier way of doing this?

You will need to use another script to change the permissions. Inside that
script the command 

   chmod(0755,"file1","file2");

should change make the file executable etc...

Good luck.

-Ben


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

Date: 21 Nov 1997 09:40:53 GMT
From: Morten Simonsen <mortensi@idt.ntnu.no>
Subject: DBM-speed
Message-Id: <653kv5$5sb$1@due.unit.no>

Hi

I plan to build a database using the regular DBM's of Perl. This
database may grow quite large and I am therefore interested in the
speed of such a database.

If I have a database at 100 MB:
-how long will it take to find a key?
-how will it perform with respect to memory?
-how long will it take to insert a new key?

For the sake of the argument, let's say the machine is a regular PC,
32 MB RAM, 200 MHz Pentium.

It's possible to answer these questions exact, but if someone has an
qualified opion, I would like to hear it.

Thanks in advance

Morten Simonsen


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

Date: Thu, 20 Nov 1997 23:15:14 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Error 2009, a hard one to solve
Message-Id: <2d5356.p14.ln@localhost>


[ no Perl in here. Followups trimmed ]


Charlie Hope-Lang (gaw29@dial.pipex.com) wrote:
: Does anyone know what the following server error means and what can be done
                                      ^^^^^^^^^^^^

Perl does not have a server.

You are more likely to get answers to a server question in a
newsgroup that has some connection to servers, such as:

   comp.infosystems.www.servers.mac
   comp.infosystems.www.servers.misc
   comp.infosystems.www.servers.ms-windows
   comp.infosystems.www.servers.unix
   comp.infosystems.www.authoring.cgi


: to eradicate it, we are using NT 3.51, Citrix 1.6 SP5 and Oracle Forms.  The
: server is a Sequent with 4*p-Pro 200 and 2 Gb RAM.  The swap file is 4 Gb.

: Additionally what is the maximum size you can set a swapfile to and does any
: one know of any software that will load a server for stress testing.

You are more likely to get answers to an operating system question in a
newsgroup that has some connection to operating systems, such as
all of the newsgroups you posted to except c.l.p.m  ;-)


: thanks for any help,  we are really stumped by this one


You are asking in the wrong place.

Do you have a perl question?


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Fri, 21 Nov 1997 09:49:53 +0100
From: Martin <techno@pedal.se>
Subject: Error when closing database connection
Message-Id: <34754B31.BB826653@pedal.se>

My CGI-script fetches data from an SQL-server (using win32::ODBC) and
generates HTML tables containg the information. At the end of the script
I tried to call the close( ) function but received strange errors.
The lines of inportance are:

use win32::ODBC;
$DSN = "budwin";
$db = new Win32::ODBC($DSN);
$db->Sql("SELECT .........");
$db->close();

When calling "close()" perl returns:
Goto undefined subroutine &autoloader::AUTOLOAD at [path]ODBC.pm line
861.

When I remove the line "$db->close();" the script executes without
errors but I am not sure what this means. Can I remove this line without
risking to leave open connections to the SQL-server?

/M




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

Date: Fri, 21 Nov 1997 01:12:12 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: File test operators do not work as advertised!!
Message-Id: <ebohlmanEJz20C.HpC@netcom.com>

Andrew M. Langmead (aml@world.std.com) wrote:

: @dirs = grep -d, map { "/home/foo/$_" } readdir DIR;

@dirs = grep -d "/home/foo/$_", readdir DIR;

would avoid making an unnecessary copy of the directory list.



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

Date: 21 Nov 1997 05:22:25 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Finding the longest common prefix over a list of strings
Message-Id: <6535qh$849$1@agate.berkeley.edu>

In article <652nbl$kgi1@eccws1.dearborn.ford.com>,
Ken Fox <kfox@ford.com> wrote:
> The last couple of "what's the best way to do it" questions put
> me into a regex hunting mood.  I had a bit of code in a file
> browser class which finds the common string prefix in a list of
> strings.  Here's the basic algorithm:

If *using* Text::Trie is an overkill, you may try to look for the
*algorithm* used there.

Ilya


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

Date: Thu, 20 Nov 1997 23:34:56 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: giving up on flock
Message-Id: <ebohlmanEJyxI8.2K4@netcom.com>

Steve (syarbrou@ais.net) wrote:
: I've pretty much had it with flock.  I open a file to read and
: append(+>>) and it just doesn't seem to work.  My file keeps getting
: cleared.  Can flock only work for reading or writing?  I hear this

Your problem isn't with flock.  It's with the way you're opening your 
file.  If you would take a look at the entry for open() in perlfunc(3), 
you would find that prefixing the name of a file to be opened with "+>>" 
is supposed to do what it's doing to you, namely creating a new file (if 
there's an old one, it will get wiped out), and then opening it for both 
reading and appending.  In that same documentation, you will also see the 
correct syntax for doing what you want to do, namely opening an existing 
file for both read and append.



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

Date: Thu, 20 Nov 1997 14:56:26 -0500
From: "jeff stanier" <stanier@neuma.com>
Subject: How Do I delete a file?
Message-Id: <6524lu$go0$1@news.intranet.ca>

Hello All.

My problem is that opening a file for writing creates a file regardless of
whether I actually write to it.  I do not want to create a file if I don't
write to it.   I can test if the file is empty, but I can't figure out how
to delete it.

P.S.  I am testing on NT but the script will be run on HP-UX and NT.

Thanks






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

Date: Thu, 20 Nov 1997 15:53:01 -0500
From: "jeff stanier" <stanier@neuma.com>
Subject: Re: How Do I delete a file?
Message-Id: <652803$hc1$1@news.intranet.ca>

Never mind!  I found it myself thanks to Tom Phoenix's hint.
Perlfunc(1) will explain unlink.

Unlink ... now why didn't I guess that.
Jeff Stanier.

jeff stanier wrote in message <6524lu$go0$1@news.intranet.ca>...
>Hello All.
>
>My problem is that opening a file for writing creates a file regardless of
>whether I actually write to it.  I do not want to create a file if I don't
>write to it.   I can test if the file is empty, but I can't figure out how
>to delete it.
>
>P.S.  I am testing on NT but the script will be run on HP-UX and NT.
>
>Thanks
>
>
>
>




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

Date: Fri, 21 Nov 1997 13:48:33 +0800
From: Lau Eng Fong <lauef@pacific.net.sg>
Subject: Re: is it possible to reference a sub-array?
Message-Id: <347520B0.B8A79B38@pacific.net.sg>

Tom Phoenix wrote:

> On 7 Nov 1997, Mark Mielke wrote:
>
> >    function(@ARGV[2..$#ARGV]);        # pass array in.
> >
> > or,
> >
> >    function( [ @ARGV[2..$#ARGV] ] );  # pass by reference.
>
> To say that the second is using "pass by reference" is a bit misleading.
> The "reference" in this case is a (Perl) reference to an anonymous
> variable which will likely be destroyed after the function returns. But in
> computer science, the concept of passing data to a function by reference
> means that the function is able to make persistent changes to the
> variables being passed. That happens in the first case, but not in the
> second.
>

I don't quite understand the above.
In computer science, there are 2 types i.e. pass by value and pass by
reference.
>From my understanding, pass by value means creating another copy of the
variable while pass by reference allows the subroutine to modify the original
ones.
It seems to me that the first case is by "pass by value" since you pass in
the  array
slice while the second case seems to be "pass by reference".



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

Date: 21 Nov 1997 02:01:24 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: is it possible to reference a sub-array?
Message-Id: <lq17ma2n323.fsf@bmers2e5.nortel.ca>

Lau Eng Fong <lauef@pacific.net.sg> writes:
> Tom Phoenix wrote:
> > On 7 Nov 1997, Mark Mielke wrote:
> > >    function(@ARGV[2..$#ARGV]);        # pass array in.
> > > or,
> > >    function( [ @ARGV[2..$#ARGV] ] );  # pass by reference.
> > To say that the second is using "pass by reference" is a bit misleading.
> > The "reference" in this case is a (Perl) reference to an anonymous
> > variable which will likely be destroyed after the function returns. But in
> > computer science, the concept of passing data to a function by reference
> > means that the function is able to make persistent changes to the
> > variables being passed. That happens in the first case, but not in the
> > second.
> I don't quite understand the above. In computer science, there are 2 types
> i.e. pass by value and pass by reference. From my understanding, pass by
> value means creating another copy of the variable while pass by reference
> allows the subroutine to modify the original ones. It seems to me that the
> first case is by "pass by value" since you pass in the array slice while
> the second case seems to be "pass by reference".

The idea is that theoretically it is passing a reference in. The problem
is that the reference is to a copied array. i.e. if function() were to
modify @_, @ARGV would be unaffected. It's a minor technicality... but
that's the way it is. Perl can't pass array slices around "by reference",
but it can pass a reference to a copy of an array slice :-) If that makes
sense :-)

Thanks for the defense though :-)

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Fri, 21 Nov 1997 09:52:22 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: is it possible to reference a sub-array?
Message-Id: <3477526f.2066113@news.tornado.be>

l41484@alfa.ist.utl.pt (Umm) wrote:

>I want to do something like:
>
>&function(\@ARGV[2]);
>
>is it possible???

I've tried this:

	@ary = qw(A B C D E);
	&function(\@ary[2..$#ary]);

It compiles, but it doesn't work ("not an array reference"). The easiest
way is to use the array slice as filling for a new anonymous array,
although I think for large arrays there MIGHT be a more efficient way
(now all elements are copied into a new array):

	&function([@ary[2..$#ary]]);

This one DOES work as you'd want it to work.


But this one triggered a question for the Perl gurus: Why do these both
return the last array element

	$ary[$#ary]
	$ary[-1]

but this slice doesn't do anything?

	@ary[2.. -1]

(replacing "-1" by "$#ary" makes it work)

This behaviour doesn't seem consequent.

	Bart.


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

Date: Thu, 20 Nov 1997 22:48:49 -0500
From: Jeremy Zifchock <jz32@cornell.edu>
Subject: New to perl.   What's wrong with this script?
Message-Id: <347504A1.7257@cornell.edu>

I am trying to have a page that can give directions to events in my area
that can be updated by another page.  here's my script, but it doesn't
work.  Can anyone help?  Thanks in advance
_______________________________________________________________________
#!/usr/local/bin/perl -w

@Hash = split(/+/$ENV{'QUERY_STRING'});

	foreach (@Hash) {
		%contents = split(/=/$_);

open (FILE,">> /www/uid/dir.html");
print FILE << "EOM";
<html>
<head>
	<title>Directions</title>
</head>

<BODY>
<p><p><b>Directions</b>
<hr>
<form>
<textarea rows=10 cols=50>
</textarea><br>
<input type="submit" value = "Send">
<input type="reset" name="reset" value = "Reset">
</form>
</body>
</html>
EOM;


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

Date: Fri, 21 Nov 1997 14:57:05 +0800
From: Andrew Ellerton <andrewe@technologyXchange.com>
Subject: open, seek and monitoring email
Message-Id: <347530C1.29AEC75F@technologyXchange.com>

Hi all,

I'm trying to write some code to monitor email spool files and do
anything once new email is received.

Although the approach may be wrong, I'm presently trying this using code
virtually straight out of Programming Perl:

for (;;) {
	while (<SPOOL>) {
	
		process_in_whatever_way();
        }
	sleep $for_a_while;
	seek SPOOL, 0, 1; # reset end-of-file error
}

Is the sleep-then-seek method a reasonable way to handle this? If anyone
has any suggestions on an alternative, and/or the use of Mail::Header to
extract header information, I'd be most thankful. 

Thanks,
Andrew
--
Andrew Ellerton                          andrewe@technologyXchange.com
Software Engineer                                      +61 8 9367 7006
International Technology Exchange                  Fax +61 8 9367 7343
Australia                             http://www.technologyXchange.com


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

Date: Thu, 20 Nov 1997 23:55:09 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Perl 5's glob() function
Message-Id: <ebohlmanEJyyFx.3C4@netcom.com>

Tad McClellan (tadmc@flash.net) wrote:

: That must be those spiffy DX2-66s that were top-of-the-line when 
: Perl 4 was used  ( just to give a little context  ;-)

NB: Perl 5.004 runs just fine on my DX2-66.



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

Date: 21 Nov 1997 08:50:41 +0100
From: ogj@tglobe3.tollpost.no (Xyvind Gjerstad)
Subject: Re: Perl 5's glob() function
Message-Id: <wroh3en0ry.fsf@tglobe3.tollpost.no>

jathan@nastything.com writes:

> I have just finished writing a script on a test machine making use of Perl
> 5's functionality and specifically, the GLOB function.
> 
> However, our production machine does not have Perl 5, but Perl 4 and
> therefore the code dependent upon the output of GLOB will not work.
> Basically, the script itself will not work.
> 
> Is there an equivalent function to GLOB for Perl 4?  Or perhaps some code
> I could use to match this:
> 
> >
> >@WorkingFiles = glob("$WorkingDir/$FileExt");

$match = "$WordkingDir/$FileExt";
@WorkingFiles = <${match}>;

will work i perl 4 and perl 5. 
-- 
Xyvind Gjerstad    Systems dept Tollpost-Globe AS  N-6301 Endalsnes/Norway
E-mail: ogj@it.tollpost.no     Phone: +47 7122 6663     Fax: +47 7122 6694


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

Date: 21 Nov 1997 01:36:24 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Perl Enhancement (was: Re: Last element of an anonymous array)
Message-Id: <lq1afeyn47r.fsf_-_@bmers2e5.nortel.ca>

norm@turing.une.edu.au (Norman Gaywood) writes:
> But! All this is a side issue! My fault for not asking the question
> properly. I just asked the question in the context that I came across
> the problem. Mark Mielke <markm@nortel.ca> frames my question in a much
> better way:
> > In perl you can do things like:
> >    $hour = (localtime)[2];
> > The question as to whether you can say:
> >    @all_but_first = (localtime)[1..];
> > I can only say... i wish :-) In fact i tried it before in hope or
> > something... but it seems the ".." operator is simply that. It's not
> > special when "in array element number context" :-) The only way i
> > know of how to do it now is:
> So the real answer to the question is no. You can't in general know
> what the last element of an array is when subscripting. You have to
> keep track of a reference or the name of the array in some way.
> 
> I'm sure others must have discussed this before but... Should the syntax
> for this be (in perl 6 or whatever):
> 
>   @all_but_first = (localtime)[1..-1];
> 
> generalising, you can do slices like [1..-3] or [-4..2] which would
> pull (2,3) from (1,2,3,4,5).

How about this :-) Rather than having 1..10 evaluate to (1,2,3,...,9,10)
which is... just sorta... wrong when it comes to memory concern... how about
'..' returns an internally tie()'d array when both sides are valid integers.
How to best explain this... hmm...

   1..576   - It's easy to know that the 1st element is 1, the 8th element
              is 8, the 200th element is 200, etc. What about if this array
              which currently evaluates into an array of constant values
              is dynamically represented in a minimalistic fashion? :-)

A similar structure to the below could be used to represent the return
value of 1..576:

   package ArrayOfSequentialIntegers;
   sub TIEARRAY {
      my $class = shift;
      my $this = {lower_bound => $_[0], upper_bound => $_[1]};
      bless $this, $class;
   }
   sub FETCH {
      my($this, $index) = @_;
      $this->{lower_bound} + $index;
   }
   sub STORE {
      die "Constant array can not be modified!\n";
   }
   sub ELEMENTS {    # NOTE: This isn't IMPLEMENTED for tie()'d array! bleh...
      my $this = shift;
      if (@_) {
         die "Constant array length can not be modified!\n"
      }
      $this->{upper_bound} - $this->{lower_bound} + 1;
   }

Of course... it would help if this could be done in XS for speed :-)

This way:

   for (1..1000000) {
   }

Would _not_ be required to create that huge temporary array. I don't know
about the 1..-1 thingy... (would result in (1,1) would it not? :-) ) but
i think that the representation "5.." could create one of these tie()'d
thingies with no upper bound... of course it would have to be a compile
time error to say:

   @a = (1.., 2);

I think perl would have trouble representing that... :-) This screwed up
idea would allow one to say:

   @fourth_field_an_on = (split(/\s+/, $_))[3..];

As well the:
   for (1..1000000) {
   }

could figure out that it's operand was of type "ArrayOfSequentialIntegers"
and simply look at the lower_bounds/upper_bounds attributes... much much
faster... :-)

any thoughts? :-)

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Fri, 21 Nov 1997 00:01:12 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Perl for NT Bug ?
Message-Id: <ebohlmanEJyyq0.3K0@netcom.com>

Amias (amias@mindless.com) wrote:
: I am having a problem with PERL on NT .
: When i run my perl program through my webserver it ignores my while loop
: but if run from the command line its fine , the source is as follows .

[Amias says there's no permission problem]

: open FILE,"$fil";

How do you know that the open is succeeding?  When running as a CGI 
script, the usual "or die" method isn't the best way to check, so do 
something like:

unless (open FILE,"$fil") {
  print "content-type: text/html\n\n";
  print <<ENDERR;
<TITLE>File open error</TITLE>
<P>Attempt to open file $fil failed due to $!
ENDERR
exit;
}

No point in guessing at the cause of the problem when Perl can tell you.



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

Date: Fri, 21 Nov 1997 08:56:56 GMT
From: Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk>
To: <amias@mindless.com>
Subject: Re: Perl for NT Bug ?
Message-Id: <b157cd$83838.1af@news.cegelecproj.co.uk>

[ Copy mailed ]

In article <34749299.7E51B612@mindless.com>, Amias <amias@mindless.com> writes:
> When i run my perl program through my webserver

If you're using M$ ISS, you probably want to fiddle the
registry settings in Ch. 10 of the on-line docs - specifically
the "run process with new console" one. Things like redirection
fail quietly without doing this.

> it ignores my while loop
> but if run from the command line its fine , the source is as follows .
> open FILE,"$fil";

In addition to reiterating the warning about not checking return
values, also check what string you're using for the pathname -
under NT, it's pretty easy to lose \ characters in "..." strings,
leading to invalid paths.

> Its not an user rights thing as i've run it from the command line as the
> IUSR for my machine (the webserver).

Yeah, I had this too - I was redirecting with "cmd|", and
the registry setting mentioned above burned me.
-- 
<Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
Kilbane's law of integration: standardise on protocols and file
formats, and the applications take care of themselves.



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

Date: 21 Nov 1997 09:46:35 +0100
From: Patrick Hayes <Patrick.Hayes.CAP_SESA@renault.fr>
Subject: Re: Problem with localtime and timelocal (getting the Weekday)
Message-Id: <vxj67pmljmc.fsf@goblin.pdj.renault.fr>

Bertrand Le Guen <b.leguen@renault.fr> writes:

> Hi every body,
>  in fact, i need to find the week number of any specific day, knowing
> the day, the month and the year.

Bertand must mean the _weekday_ number.

> i wrote something like this but it doesn't work !

Sure it does...

> could someone explain that to me or show me an example on how to get
> the weekday number from a date !

Yep, the weekday number.

> i didn't find anything in the FAQ so i wish someone could help !

The answer isn't in the FAQ's Bertrand, it's in the man pages (You do have
them, right?) or in the camel book (either edition).

Extracted from "perldoc perlfunc":

localtime EXPR
     Converts a time as returned by the time function to a 9-element
     array with the time analyzed for the local time zone.  Typically
     used as follows:

          #  0    1    2     3     4    5     6     7     8
          ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
          						localtime(time);

     All array elements are numeric, and come straight out of a struct
     tm.  In particular this means that $mon has the range 0..11 and
     $wday has the range 0..6 with sunday as day 0.  Also, $year is the
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     number of years since 1900, that is, $year is 123 in year 2023.

     If EXPR is omitted, uses the current time (`localtime(time)').

     In a scalar context, returns the ctime(3) value:

          $now_string = localtime;  # e.g., "Thu Oct 13 04:54:34 1994"

     Also see the Time::Local module, and the strftime(3) and mktime(3)
     function available via the POSIX module.

Pat

-- 
--------------------------------------------------------
Patrick.Hayes.CAP_SESA@renault.fr    (33) 01.41.04.64.20
--------------------------------------------------------


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

Date: Fri, 21 Nov 1997 10:24:53 +0100
From: Bertrand Le Guen <b.leguen@renault.fr>
Subject: Re: Problem with localtime and timelocal (getting the Weekday)
Message-Id: <34755365.794B@renault.fr>

Kevin Eson wrote:
> print scalar localtime(882640800);
> print "\n";
> exit;^D
> Sat Dec 20 12:00:00 1997
> [/home/keson]>
> 
> This tells me that the $month parameter to the timelocal function is not the
> actual numeric month but the zero-indexed month (0=January, 11=December).
> The results you get for the day of the week (6) would be correct, December 20,
> 1997 is a Saturday.
In french we say :
Let your tong turns 7 times in your month before saying anything ..
it means that i could have found it if i had search a little more in the
perl man :-)
I saw that the week day was 0 .. 6 but was too lazy to read it till the
end :-)

thanks 
 bertrand
-- 
(Hobby)
http://www.tamtam.insat.com (le Web en Francais sur la Musique)
(Job)
***************************** Bertrand Le Guen               
*  "If at first you don't   * CAD/CAM & SGI/Unix Admin 
*   succeed, destroy all    * Web Master (Intranet)
* evidences that you tried" * mailto:b.leguen@renault.fr
*****************************


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

Date: Fri, 21 Nov 1997 00:06:17 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Rename Ref file
Message-Id: <ebohlmanEJyyyH.3pM@netcom.com>

Bruce Davidson (b.davidson@webforums.net) wrote:
: I have two scripts which want to use the contents of a reference file.
: When I exit the first script I want to rename the file so that the
: second script can read its contents, but it will disable the first
: script from access to the ref file again.

: Would apprecite an example of
: sub rename_file {
: rename file-a file-b
               ^      ^
               ,      ;

Just put in the comma and the semicolon, and your pseudocode turns into 
real code.  If course, in real life you'll want to check to see that the 
rename was successful, and you'll want to read the documention for 
rename() to see how it handles certain special cases that you might run into.

:}



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

Date: 21 Nov 1997 00:45:35 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Safe use of flock() -- was Re: giving up on flock
Message-Id: <lq1btzen6kg.fsf@bmers2e5.nortel.ca>

"Luu Tran" <luutran@geocities.com> writes:
> Is it necessary to check whether flock is successful?
>
> [quote from man perlfunc for flock sample code]
> 
> It's not checking the flock operation.  I've always followed this example 
> and have had no problem.  Maybe I've just been lucky?

"man flock" on my system (solaris 2.5.1) tells me that possibly
error conditions are:

     EBADF               The argument fd is an  invalid  descrip-
                         tor.

     EINVAL              operation is not a valid argument.

     EOPNOTSUPP          The argument  fd  refers  to  an  object
                         other than a file.

     EWOULDBLOCK         The  file  is  locked  and  the  LOCK_NB
                         option was specified.

Although flock() should be ok 99.999% of the time... i do it... just
like i use chomp() instead of chop()... ALWAYS... :-)

Oh yeah... Tom... I just found a section in the manpage that says that:

            To avoid the possibility of mis-coordination, Perl
            flushes FILEHANDLE before (un)locking it.
                                        (man perlfunc - flock)

No need to close() the file every single time. If the log file is
going to be significantly big i will now suggest that if i were to keep
a logfile handle sitting around for re-use... it's not bad... but rather
more efficient... :-)

mark
  

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Fri, 21 Nov 1997 10:49:55 +0100
From: Yann <ycueff@club-internet.fr>
Subject: Sorting an array
Message-Id: <34755942.47C7@club-internet.fr>

I've some problems to sort an array.
Could someone help me ?
For example I'd like to sort this array by the 3rd field.

bcv64wd8:solaris:5.5:sun4m:SUN1.05:AGL
bcv67wcb:solaris:5.5.1:sun4m:SUN0535:AGL
bcv67w50:solaris:5.5.1:sun4c:SUN0424:AGL
bcv67w5b:solaris:5.5:sun4m:SUN0535:AGL
bcv66m14:AIX:3.2:::AGL
bcv66w58:sun4:4.1.3_U1:sun4m:SUN1.05:AGL
bcv95wc4:solaris:5.5.1:sun4c:SUN0424:AGL

I've try the following program but it doesn't work (@INFOS is the
array):


    local(@TEMP_INFOS); 
    foreach (@INFOS) 
    { 
        push (@TEMP_INFOS, (split(/:/))[2]); 
    } 
    sub bydatakeys { $TEMP_INFOS[$a] <=> $TEMP_INFOS[$b]; } 
    @SORT_INFOS=@INFOS[sort bydatakeys $[..$#INFOS]; 
    print join("\n",@SORT_INFOS); 

Thanks.


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

Date: Thu, 20 Nov 1997 23:24:10 -0700
From: "Ken Scott" <kscott@pcisys.net>
Subject: Suppressing echo at STDIN
Message-Id: <6539ee$pif$1@newman.pcisys.net>

Hi all,

I am new to Perl programming, and have looked in the FAQs, etc, but have not
found the solution to my question.

I am writing an interactive script that needs to ask a user for a password.
How do I keep from echoing whatever the user types to the terminal? Or if
that's not possible, turn it in to stars or hashes, or something that is not
what they typed.

If it matters, I am running my script from a standard command prompt under
Win NT 4.0

Thanks in advance for anyone's help.

Ken


--
      w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w
         Ken Scott   kscott@pcisys.net   http://www.pcisys.net/~kscott
                   This is the day that the Lord has made;
                      I will rejoice and be glad in it!
                             -- Psalm 118:24
      w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w=w






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

Date: 21 Nov 1997 07:30:40 GMT
From: beg1@axe.humboldt.edu (BEN GILBERT)
Subject: text stripping
Message-Id: <beg1-2011972336480001@sdn-ts-002caeurep04.dialsprint.net>

Hi,

I am trying to strip one sentence out of a file. Stated differently how do
I get everything in a file that is between <b> and </b>? I understand and
found a lot of material on how to do substitutions, but I want to get a
specific line (not necessarily by line number) and place it into another
file. Thanks so much.

-Ben


____________________________________________________________________
Benjamin E. Gilbert             ^    I have no special talents,
beg1@axe.humboldt.edu            ^    I am only passionately curious.
http://www.humboldt.edu/~beg1/    ^           -Einstein


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

Date: 21 Nov 1997 04:58:08 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Year2000 problem with localtime();
Message-Id: <6534d0$365$1@comdyn.comdyn.com.au>

In article <650hlo$877@gutemine.informatik.uni-kiel.de>,
	wib@cs.uni-kiel.de (Willi Burmeister) writes:

> eden{wib} perl
> print scalar localtime 2 ** 31 - 3601;
> ^D
> Tue Jan 19 03:14:07 2038
> 
> a Bug?

Also see my other post in this thread:

Your time zone variable is probably set to GMT -1.

both the gmtime and the localtime use a signed 32 bit int for the
time. That means that if you're converting times, that both of these
face the limitation of 2 ** 31 -1. For positive TZ offsets (eg. US
time zones) that just means that the gmtime one is limiting (the time
returned by time()). For people with negative time zone offsets
(Europe, Asia, Australia), the localtime is limiting.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd.       | inexactitude.
NSW, Australia                      | 


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

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 1352
**************************************

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