[18113] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 273 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 12 11:05:37 2001

Date: Mon, 12 Feb 2001 08:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981993908-v10-i273@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 12 Feb 2001     Volume: 10 Number: 273

Today's topics:
    Re: A Question on OLE and EXCEL- help please <dog222@my-deja.com>
    Re: Archive::Zip - any user comments? <matt@sergeant.org>
        Capturing output of a system command pcraven@my-deja.com
    Re: Capturing output of a system command <joe+usenet@sunstarsys.com>
    Re: Capturing output of a system command <mothra@nowhereatall.com>
        Directory listings in a table <schallerp@hotmail.com>
    Re: Editing a file if line doesn't exist already <mischief@velma.motion.net>
    Re: Finding multiply of prime factors <jonni@ifm.liu.se>
    Re: Finding multiply of prime factors <Brett.W.Denner@lmco.com>
    Re: Finding multiply of prime factors <jonni@ifm.liu.se>
    Re: flock() strategy for Win95? - eval() etc (William Herrera)
    Re: flock() strategy for Win95? - eval() etc <mkruse@netexpress.net>
    Re: Food for guru's: read/modify/write works under Linu (Abigail)
    Re: Food for guru's: read/modify/write works under Linu (Randal L. Schwartz)
        HELP WITH POP3Client module!!! <peter@viasafe.com>
        Installation Problems with Perl 5.6 on NCR Box <mcook@ga.prestige.net>
        MIME Mac problem I think! <sholana@my-deja.com>
    Re: MIME Mac problem I think! <dwilga-MUNGE@mtholyoke.edu>
    Re: Partial Apology to Perl Fans (Anno Siegel)
    Re: Perl, Solaris and readdir64 <mischief@velma.motion.net>
    Re: Perl, Solaris and readdir64 <mischief@velma.motion.net>
    Re: perlbug (Anno Siegel)
    Re: postgres perl problem (John Joseph Trammell)
        Sorting <josefiller@lucent.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Feb 2001 15:21:10 GMT
From: LoDog <dog222@my-deja.com>
Subject: Re: A Question on OLE and EXCEL- help please
Message-Id: <968v0r$4lq$1@nnrp1.deja.com>

Thank you Bart.  Have a great day!



In article <n8598tkshh0bp1fdne08uqi4hjg55b48mp@4ax.com>,
  Bart Lateur <bart.lateur@skynet.be> wrote:
> dog222@my-deja.com wrote:
>
> >use OLE;
>
> New code should use Win32::OLE instead, I think.
>
> >ERROR MESSAGE!!!!!!
> >
> >"Cant use and undefined value as a hash reference at line 5."
>
> Here's why:
>
> >$excelobject = CreateObject OLE 'Excel.Sheet';
>
> Apparently CreateObject on this line fails. Don't ask me why, there
> ought to be some way to get the error message out of perl, but I don't
> use this old module. ;-)
>
> You can get online documentation for using OLE with Perl, here:
>
> perlwin32faq12 - Using OLE with Perl
>
<http://velocity.activestate.com/docs/ActivePerl/faq/Windows/ActivePerl-
Winfaq12.html>
>
> Win32::OLE - OLE Automation extensions
>
<http://velocity.activestate.com/docs/ActivePerl/site/lib/Win32/OLE.html
>
>
> Lots of neat examples, too.
>
> --
> 	Bart.
>

--
Good luck to all Programmers!


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 12 Feb 2001 14:07:05 +0000
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: Archive::Zip - any user comments?
Message-Id: <3A87EE09.DDD90138@sergeant.org>

Tom Bates wrote:
> 
> I just tried using this module today, and have had problems. If I zip
> an Access database with WinZip, the unzip in Archive::Zip creates a
> corrupt database. It's short by about 2%, with all compression methods
> except "none".

Could you maybe not be using binmode to read/write the file(s)? I've used
Archive::Zip on Linux with no troubles.

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\


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

Date: Mon, 12 Feb 2001 15:02:23 GMT
From: pcraven@my-deja.com
Subject: Capturing output of a system command
Message-Id: <968tto$3je$1@nnrp1.deja.com>

I've got a Win32 perl script that calls the sun javac compiler using
the system command. It works great, but I have no way of capturing the
output of that command. So I can't figure out if there are any errors.

I've tried redirecting or piping the output of the javac command, but
the output isn't captured. They must not be using stdout or something.
Any ideas?


Sent via Deja.com
http://www.deja.com/


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

Date: 12 Feb 2001 10:23:37 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Capturing output of a system command
Message-Id: <m3wvawkjra.fsf@mumonkan.sunstarsys.com>

pcraven@my-deja.com writes:

> I've got a Win32 perl script that calls the sun javac compiler using
> the system command. It works great, but I have no way of capturing the
> output of that command. So I can't figure out if there are any errors.

You could always check the return value of the "system" call; and
if that isn't what you want, you could use backticks instead.

> I've tried redirecting or piping the output of the javac command, but
> the output isn't captured. They must not be using stdout or something.
> Any ideas?

See 

  % perldoc -f system

and the discussion of backticks in

  % man perlop

HTH

Joe Schaefer
-- 
#include <stdio.h> /* requires gcc and *nix
use strict; system("cc -x c $0") and die $?; open C, "|a.out" or die $! . q*/
main(){char s[32]; remove("a.out"); printf("%s/C hacker\n",fgets(s,32,stdin));
return 0;}/*; print C "Just another Perl"; close C or die $?; #*/


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

Date: Mon, 12 Feb 2001 07:19:13 -0800
From: mothra <mothra@nowhereatall.com>
Subject: Re: Capturing output of a system command
Message-Id: <3A87FEF1.80BFB5BF@nowhereatall.com>

pcraven@my-deja.com wrote:
> 
> I've got a Win32 perl script that calls the sun javac compiler using
> the system command. It works great, but I have no way of capturing the
> output of that command. So I can't figure out if there are any errors.
> 
[snipped]

try using the backticks to run the command.
ie: $out_command= `program args`;

or you can do something like this

open (YOURCMD, "program args |") or die "can't run program: $!\n";
while(<YOURCMD>)   {

  $cmdout=.$_;
}
close(YOURCMD);


I hope this helps

Mothra!


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

Date: Mon, 12 Feb 2001 15:37:19 GMT
From: Paul <schallerp@hotmail.com>
Subject: Directory listings in a table
Message-Id: <968vvf$5lj$1@nnrp1.deja.com>

I'm looking for a script that I can use that will display a directory
contents in a table in order of the file dates.

Paul

--
**To replay via email
schallerp@hotmail.com


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 12 Feb 2001 15:43:10 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Editing a file if line doesn't exist already
Message-Id: <t8g14eocm6jgb7@corp.supernews.com>

jstanley@mmm.com wrote:
> I am having trouble thinking of a way to edit a file only if a particular
> line doesn't exist.

> I am using the following.  I need to be able to read through a file and look
> for a particular line.  If that line is not found then it should be added to
> the end of the file.  Unfortunately the way I am doing it now, the WHILE
> statement checks each line in the file and adds test to the bottom of the
> file for everytime it doesn't find a match.  I only want it to add a line at
> the bottom if it doesn't find a match after going through the whole file.

The really short answer is:
    You want to change state to true if the line is found.

The short answer is:
    If you want to do something once, move it outside the loop.
    Have the logic inside the loop indicate what should be done
    after the loop.

The medium answer is:
    Have your while loop test if you have found the line, and
    if so, set a variable showing it was found. After the loop,
    if the line was not found, append it to the file.

The long and really long answers are left as an exercise. ;)
 
The code answer looks something like this:

#---------------------------------
    ### See Note 1
open( File, "conf/my.conf" ) || die "Can't open file: $!\n";
my $line_found = 0;
while( <File> ) {
    if( m/pattern_unqiue_to_line_goes_here/ ) {
        $line_found = 1;
        last; ### see Note 2
    }
}
close(File);
unless( $line_found ) {
    open( File, ">> conf/my.conf" ) || die "Can't open file: $!\n";
    print File "whatever line should look like goes here";
    close( File );
}
#---------------------------------

Note 1:
   Always check the return of open() one way or another. This
   is good advice for all system calls, but especially for open().

   Remember, too, that you can use forward slashes for
   directories when programming on Windows. No need to use ugly
   double backslashes.

Note 2:
   The call to q<last> here can save you an average of one half
   the time in the loop, if your line is equally likely to be
   anywhere in the file. Even more if it's most likely to be in
   the first few lines. Less if it's most likely to be at the end.

   Unfortunately, since you append the line if it's not already
   there, the use of q<last> may not save you much. If this program
   will be run often on very large files, consider prepending
   the line. There are multiple ways to prepend to a file, but
   that's beyond the scope of this article and would be a good
   item for further research.

The rude answer would have been:
   This is a problem with the logic of the program, not a
   question about the implementation language. You would be
   better served asking in another group, perhaps in one that
   specializes in algorithms. ### see Note 3

Note 3:
   Although the entirety of the "rude answer" would have been
   rude, the first sentence is true and the second is not
   necessarily true (it's not true in this case, as the problem
   is simple enough for any programming group to answer).

   The question really is about the program logic and not Perl.
   This group should be nice enough to help people learn the
   difference instead of chastising them for the confusion OR
   quietly showing the corrected code and not mentioning that
   the answer is not specific to Perl.

My apologies to the OP for getting on my soapbox to the group
while answering you question. ;)

Chris

-- 
Christopher E. Stith

If they can get you asking the wrong questions, they don't
have to worry about the answers.
  -- Thomas Pynchon, Gravity's Rainbow



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

Date: Mon, 12 Feb 2001 15:20:23 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: Finding multiply of prime factors
Message-Id: <968rda$pbd$1@newsy.ifm.liu.se>

Heres a nice quick one that does it recursively.

sub factorize {
         return(2,factorize($_[0]/2)) if (($_[0]%2)==0);
         my $limit=int(sqrt($_[0]));
         my $i=3;
         while ($i<=$limit) {
          if ($_[0]%$i==0) {return($i,factorize($_[0]/$i))};
          $i+=2;
     }
     return $_[0];
}

$a=int rand 1e8;
print "$a = ",join(" x ",factorize($a));


--
 _____________________     _____________________
|   Jonas Nilsson     |   |                     |
|Linkoping University |   |      Telephone      |
|       IFM           |   |      ---------      |
| Dept. of Chemistry  |   | work: +46-13-285690 |
|  581 83 Linkoping   |   | fax:  +46-13-281399 |
|      Sweden         |   | home: +46-13-130294 |
|_____________________|   |_____________________|
"Verbitum Fong" <verbitumfong@hotmail.com> wrote in message
news:968caq$et2@netnews.hinet.net...
> For example:
> 48 = 2 x 2 x 2 x 2 x 3
> 121 = 11 x 11
> 12345 = 3 x 5 x 823
>
> I wrote a program
>
> $input = $compute = 12345;
> while($compute>1) {
>     for $i (2..$compute) {
>         $temp = $compute/$i;
>         if($temp == int($temp)) {
>             push @result,$i;
>             $compute = $temp;
>             last;
>         }
>     }
> }
> print "$input = ",join(" x ",@result),"\n";
>
> Although it shows correct answer, I feel it is not so good,
> especially the for $i loop.  Besides, I am afraid it might
> loop infinitely.  If sometimes "rounding error" make
> the == test fails, the program will hang.
>
> Would you rectify my program to avoid that and make better?
> Thanks.
>
> Verbitum Fong
>
>
>




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

Date: Mon, 12 Feb 2001 08:27:26 -0600
From: "Brett W. Denner" <Brett.W.Denner@lmco.com>
Subject: Re: Finding multiply of prime factors
Message-Id: <3A87F2CE.481CDED2@lmco.com>

Jonas Nilsson wrote:
> 
> use:
> if (($compute % $i)==0) {
>              push @result,$i;
>              $compute = $compute/$i;
>              last;
> 
> instead of:
> >         $temp = $compute/$i;
> >         if($temp == int($temp)) {
> >             push @result,$i;
> >             $compute = $temp;
> >             last;
> 
> Also, $i need to be only primes (2,3,5,7,11,13) less than sqrt($compute). So
> you can minimize computation by going through 2 and every uneven number less
> than sqrt($compute)   (2,3,5,7,9 .. int(sqrt($compute))

I don't understand why the sequence stop at int(sqrt($compute)).  The prime
factors of
12345 are 3, 5, and 823; the last prime factor (823) is certainly much
higher than
sqrt($compute).

Brett


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

Date: Mon, 12 Feb 2001 16:59:27 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: Finding multiply of prime factors
Message-Id: <969172$qq4$1@newsy.ifm.liu.se>

OK. To clarify:

12345 = 3*5*823.

Start with primes: 12345 (int sqrt 12345=111(limit))
12345 % 2  (not 0, so 2 isn't factor)
12345 % 3 (is 0, so 3 is factor)

Continnue with 12345/3=4115 (int sqrt 4115=64(limit))
4115 % 2 (not 0)
4115 % 3 (not 0)
4115 % 5 (is 0 so 5 is factor)

Continnue with 4115/5=823 (int sqrt 823=28(limit))
823 % 2 (not 0)
823 % 3 (not 0)
823 % 5 (not 0)
823 % 7 (not 0)
823 % 11 (not 0)
823 % 13 (not 0)
823 % 17 (not 0)
823 % 19 (not 0)
823 % 23 (not 0)
823 % 29 (not 0, 29>28(limit reached))
This means 823 has no divisor and is a prime. So result: 3*5*823

Actually you don't need to repeat tries with 2 the second time and with 2,3
the third since these are allready tried before.

Get it?
See my earlier post for a working codeexample.
/jN





--
 _____________________     _____________________
|   Jonas Nilsson     |   |                     |
|Linkoping University |   |      Telephone      |
|       IFM           |   |      ---------      |
| Dept. of Chemistry  |   | work: +46-13-285690 |
|  581 83 Linkoping   |   | fax:  +46-13-281399 |
|      Sweden         |   | home: +46-13-130294 |
|_____________________|   |_____________________|
"Brett W. Denner" <Brett.W.Denner@lmco.com> wrote in message
news:3A87F2CE.481CDED2@lmco.com...
> Jonas Nilsson wrote:
> >
> > use:
> > if (($compute % $i)==0) {
> >              push @result,$i;
> >              $compute = $compute/$i;
> >              last;
> >
> > instead of:
> > >         $temp = $compute/$i;
> > >         if($temp == int($temp)) {
> > >             push @result,$i;
> > >             $compute = $temp;
> > >             last;
> >
> > Also, $i need to be only primes (2,3,5,7,11,13) less than
sqrt($compute). So
> > you can minimize computation by going through 2 and every uneven number
less
> > than sqrt($compute)   (2,3,5,7,9 .. int(sqrt($compute))
>
> I don't understand why the sequence stop at int(sqrt($compute)).  The
prime
> factors of
> 12345 are 3, 5, and 823; the last prime factor (823) is certainly much
> higher than
> sqrt($compute).
>
> Brett




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

Date: Mon, 12 Feb 2001 14:24:37 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: flock() strategy for Win95? - eval() etc
Message-Id: <3a87f1eb.41862729@news.rmi.net>

On Mon, 12 Feb 2001 04:51:57 GMT, "Matt Kruse" <mkruse@netexpress.net> wrote:

>In previous versions of ActivePerl for Windows, any flock() call would die
>in Win95.
>With the current version, it doesn't cause any errors but instead just does
>nothing.

You could use the File::FlockDir module on CPAN to implement flock on Win9x.


---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.


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

Date: Mon, 12 Feb 2001 09:29:09 -0600
From: "Matt Kruse" <mkruse@netexpress.net>
Subject: Re: flock() strategy for Win95? - eval() etc
Message-Id: <3a8800b0$0$21432@wodc7nh0.news.uu.net>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Traditional file lock is not supported on Win 9.x systems.

I knew this ;)

> Have a look at this page for an answer:
> http://language.perl.com/newdocs/pod/perlopentut.html#File_Locking

I'm not sure how this helps. It doesn't mention win9x limitations of flock,
and it uses flock in every example without checking for failure. So
basically, it will appear to work on win9x (ie, it won't fail) while in fact
it doesn't do any locking. This is what I'm trying to avoid.

Matt Kruse
http://www.mattkruse.com/






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

Date: 12 Feb 2001 14:07:17 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Food for guru's: read/modify/write works under Linux, not under Solaris. Please help!
Message-Id: <slrn98frgl.hhu.abigail@tsathoggua.rlyeh.net>

Frank van Wensveen (fw@lanvision.nl) wrote on MMDCCXXII September
MCMXCIII in <URL:news:evpf8t8vpd6dr528lhik63da2ch177enp5@4ax.com>:
[] 
[] Working from the assumption that this is indeed a buffering problem, I
[] went to perldoc.com to learn how to autoflush file handles. It turned
[] out that putting
[] 
[]   select ((select (FILE), $| = 1) [0]);      # Autoflush on
[] 
[] and 
[] 
[]   select ((select (FILE), $| = 0) [0]);      # Autoflush off
[] 
[] around my read/modify/write subroutine did the trick!


This is highly obscure and smells like carg-cult. Could you also explain
what it does, and why this is better than using a few short lines?



Abigail
-- 
perl -wle'print"Êõóô áîïôèåò Ðåòì Èáãëåò"^"\x80"x24'


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

Date: 12 Feb 2001 06:52:51 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Food for guru's: read/modify/write works under Linux, not under Solaris. Please help!
Message-Id: <m1bss89cn0.fsf@halfdome.holdit.com>

>>>>> "Abigail" == Abigail  <abigail@foad.org> writes:

Abigail> []   select ((select (FILE), $| = 0) [0]);      # Autoflush off

Abigail> This is highly obscure and smells like carg-cult. Could you
Abigail> also explain what it does, and why this is better than using
Abigail> a few short lines?

I find it amusing that Abigail is calling the nested-select device
which I created in 1989 "carg[o]-cult". :)

Perhaps in the fact that it's being used as "magick" makes it so, but
it's a reasonably compact solution to a common problem.

print "Just another Perl hacker,";

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Mon, 12 Feb 2001 15:59:57 GMT
From: "Magma" <peter@viasafe.com>
Subject: HELP WITH POP3Client module!!!
Message-Id: <1MTh6.2438$f5.345298@news>

I am using a POP3Client object to receive e-mail messages to my script.
My problem is that I can't seem to find a way to tell if it is currently connected!
I need my script to automatically re-establish it's connection when it is lost (due to a network outage or whatever), so this is
imperative.

All the obvious methods one would call return false (as expected) BEFORE connecting. Once connected, it's an all new ballgame.
I start my script, it connects, it receives messages. I then unplug my network cable to simulate a network loss. All the methods
keep returning true.

List returns the number of messages last listed.
Alive seems to always be true.
Count returns the last count.
State returns transaction.

I am at a loss.
Any help would be greatly appreciated.




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

Date: Mon, 12 Feb 2001 15:00:51 GMT
From: "J. Morris Cook, Jr." <mcook@ga.prestige.net>
Subject: Installation Problems with Perl 5.6 on NCR Box
Message-Id: <DUSh6.2481$hQ5.13284@skycache.prestige.net>

I am attempting to install Perl 5.6 on an NCR SVR4 Unix box running MPRAS,
with all current patches to OS. When I run make, I get the following error
as it dies:

w "toke.c",L4976: Perl_yylex: Global CSE elimination suppressed; function is
too
 big.
Memory exhausted (malloc returned 0)
While allocating 16000 byte chunk for pool live/dead vectors

Aborting(1)...
*** Error code 1 (bu21)

make: fatal error.

I would appreciate any help anyone can give!
Thanks in advance!





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

Date: Mon, 12 Feb 2001 14:08:48 GMT
From: Sholana <sholana@my-deja.com>
Subject: MIME Mac problem I think!
Message-Id: <968qpb$oo$1@nnrp1.deja.com>

on a Mac with Netscape 4.70, I get the following message. I thought it
might be a cache thing at work, so tested the cards from home with my
Mac using Netscape Communicator 4.7, I get the same error message below:

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.

Any clues ? A PC works fine!!!!!


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 12 Feb 2001 15:49:02 GMT
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: MIME Mac problem I think!
Message-Id: <dwilga-MUNGE-5F9BF3.10450212022001@news.mtholyoke.edu>

In article <968qpb$oo$1@nnrp1.deja.com>, Sholana <sholana@my-deja.com> wrote:

> on a Mac with Netscape 4.70, I get the following message. I thought it
> might be a cache thing at work, so tested the cards from home with my
> Mac using Netscape Communicator 4.7, I get the same error message below:
> 
> 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.

This is not a Perl question. I suggest you try asking in 
comp.infosystems.www.servers.unix instead.

The problem most likely has to do with your web server's configuration (the 
Limit directive in Apache, for instance), not your browser.

-- 
Dan Wilga          dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **


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

Date: 12 Feb 2001 14:30:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Partial Apology to Perl Fans
Message-Id: <968s1j$hql$1@mamenchi.zrz.TU-Berlin.DE>

 <topmind@technologist.com> wrote in comp.lang.perl.misc:
>Dear Perl Fans,
>
>A couple of years ago I started a "criticisms of Perl" rant on the

Wow!  That's pre-historic by usenet standards.

[...]

>Thus, as long as Perl fans can read each other's Perl code and be
>productive, it does not matter if I or other non-fans cannot do
>the same with Perl. Similarly, you perhaps would not like applications
>that I design. (Note that I have not verified whether Perl fans can
>read each other's code.)

I don't know who around here would self-qualify as a "Perl fan",
but of course we can read each other's code.

Actually, the whole question is besides the point.  A programmer
can read code written in any language.  Access to the documentation
is essential, prior knowledge of the language is a bonus.  The only
requirement to the source is that it be decently written.

Anno


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

Date: Mon, 12 Feb 2001 14:49:34 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Perl, Solaris and readdir64
Message-Id: <t8ftvuc0uku682@corp.supernews.com>

James Pearson <j.pearson@ge.ucl.ac.uk> wrote:
> I have a perl (v5.005_02) script that is running on Solaris 2.6 (sparc)
> that uses find.pl, but is failing to read the contents of a certain
> directory.

> The directory in question is NFS mounted from an SGI - find($dir) does
> not find anything in the directory (although it contains over 700
> files).

Several programs have limitations about working across NFS.

> I can reproduce the problem with the following:

> opendir(DIR,$dir);
> @filenames = readdir(DIR);
> closedir(DIR);
> print "@filenames\n";

> For the directory in question - readdir() returns an empty list (the
> directory is readable ...) - not even the "." and ".." entries.

> However, this doesn't seem to be a perl problem (in fact it *may* be a
> problem with the "version" of the XFS filesystem on the SGI - but I
> can't doing anything about that).

> I can reproduce the same problem with some C code:

> dirp = opendir(dir);
> while ((dp = readdir(dirp)) != NULL)
>   printf("%s ", dp->d_name);
> closedir(dirp);

> If I replace readdir() in the C code with readdir64(), then it works OK
> - the contents of the directory in question are printed out ...

Then perhaps the readdir() in your C libraries is the culprit.
Sounds to me like your system readdir() doesn't deal with NFS
and that Perl's readdir() is based upon it.

> So my question is, can I do something similar in perl? Can I force perl
> on Solaris to use readdir64() somehow? Or, is there some sort of
> readdir64 for perl available via a module etc.?

If you are confident you'll have readdir64() in the system library
everywhere your script will run, you might make use of Perl's
syscall() function which lets you call an arbitrary system call
and returns the results of same. 

If you got really ambitious, you could write a module that uses
the working method of reading a directory across NFS for whichever
platform, whether on a certain platform that is readdir(),
readdir64(), or something else.

Chris
-- 
Christopher E. Stith

Try not. Do, or do not. The Force is binary. -- Yoda,
The Empire Strikes Back (paraphrased)



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

Date: Mon, 12 Feb 2001 14:55:24 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Perl, Solaris and readdir64
Message-Id: <t8fuasrtm03tcb@corp.supernews.com>

James Pearson <j.pearson@ge.ucl.ac.uk> wrote:
> I have a perl (v5.005_02) script that is running on Solaris 2.6 (sparc)
> that uses find.pl, but is failing to read the contents of a certain
> directory.

[snip]

> I can reproduce the same problem with some C code:

[snip C code]

> If I replace readdir() in the C code with readdir64(), then it works OK
> - the contents of the directory in question are printed out ...

> So my question is, can I do something similar in perl? Can I force perl
> on Solaris to use readdir64() somehow? Or, is there some sort of
> readdir64 for perl available via a module etc.?

I forgot to mention in my other post... Take a look on CPAN
at module File::Find, and see if that helps. I'm not sure if
it will do what you need, over NFS and all. I've never used
this module myself, but I hear it is very useful in doing
directory scanning.

Chris

-- 
Christopher E. Stith

You must not lose faith in humanity. Humanity is an ocean;
if a few drops of the ocean are dirty, the ocean does not
become dirty.  -- Mohandas K. Gandhi



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

Date: 12 Feb 2001 14:49:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perlbug
Message-Id: <968t4u$hql$2@mamenchi.zrz.TU-Berlin.DE>

Joseph Gottman <joegottman@worldnet.att.net> wrote in comp.lang.perl.misc:
>I have been trying to report a bug, and every time I send an e-mail to
>perlbug@perl.com, it bounces back two or three days later.  How should I
>report the bug?

The perlbug utility worked fine last time I used it.  Yes, it sends mail
to perlbug@perl.com.

Anno


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

Date: Mon, 12 Feb 2001 15:39:19 GMT
From: trammell@bayazid.hypersloth.net (John Joseph Trammell)
Subject: Re: postgres perl problem
Message-Id: <slrn98fur9.vvh.trammell@bayazid.hypersloth.net>

On Mon, 12 Feb 2001 08:33:37 +0100, Tony Dalbrekt <to.da@spray.se> wrote:
> Can't locate pg.pm in @INC (@INC contains: /usr/lib/perl5/5.6.0/i386-linux
> /usr/lib/perl5/5.6.0 /usr/lib/perl5/site_perl/5.6.0/i386-linux
> /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at
> /home/toda/html//cgi-bin/test.cgi line 8.
> 
> Why do I get this error message every time I try to connect to my postgres
> database.

Probably because of that bug on line 32 of your code.



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

Date: Mon, 12 Feb 2001 16:58:19 +0100
From: Karl-Jose Filler <josefiller@lucent.com>
Subject: Sorting
Message-Id: <3A88081B.71B391EC@lucent.com>

This is a multi-part message in MIME format.
--------------1B5017C5B8A333BEC2B52702
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm trying to sort "data structures"
Example code:

use strict ;
my ($i, @l);

for $i (1..100) {
  $l[$i]->{'X'} = $i;
}
for $i (sort({$b->{'X'} <=> $a->{'X'} } @l)) {
  print "$i $i->{'X'} \n";
}

But my perl says
nbgh087[180] perl x.pl
Modification of a read-only value attempted at x.pl line 7.


Any hint ?


--------------1B5017C5B8A333BEC2B52702
Content-Type: text/x-vcard; charset=us-ascii;
 name="josefiller.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Karl-Jose Filler
Content-Disposition: attachment;
 filename="josefiller.vcf"

begin:vcard 
n:Filler;Karl-Jose
tel;cell:+49-170-5627564
tel;work:+49-911-526-2870
x-mozilla-html:FALSE
org:Lucent Technologies;BSC DFS
adr:;;Thurn und Taxis Str. 10;Nuernberg;;90411;Germany
version:2.1
email;internet:josefiller@lucent.com
fn:Karl-José Filler
end:vcard

--------------1B5017C5B8A333BEC2B52702--



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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