[7386] in Perl-Users-Digest
Perl-Users Digest, Issue: 1011 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 11 12:17:35 1997
Date: Thu, 11 Sep 97 09:00:36 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 11 Sep 1997 Volume: 8 Number: 1011
Today's topics:
Re: (no subject) <petri.backstrom@icl.fi>
Re: divide by zero problem in reports. (Nigel Reed)
Re: flock in Win32? <petri.backstrom@icl.fi>
Re: flock in Win32? (SJK)
Re: Flushing STDOUT? <helgek@berlin.snafu.de>
Re: Help on 'system' function <pbarone@rsa.hisd.harris.com>
How to check if a file exits! <mikeg@slpma8.ed.ray.com>
Re: How to check if a file exits! <eike.grote@theo.phy.uni-bayreuth.de>
How to connect to Oracle database <ishen@ciscorp.com>
how to generate permutations of an array brian.hoffman@starkist.com
Re: How to open a file for both read and write (William Wue(2xP)elma(2xN))
Is there a simpler syntax for: defined $a && $a ne '' <Brett.W.Denner@lmtas.lmco.com>
Re: Korn Shell to Perl <seay@absyss.fr>
Re: Macperl: Selena Sol's Groupware Calendar (Chris Nandor)
Re: make: *** File Makefile' has modification time in t <clark@s3i.com>
manipulating chars inside strings? (Yoav Zach)
Net::Whois unsetting $/? (Tony Bowden)
PERL 5 for Alpha OpenVMS <dmills@riag.com>
Perl and Nt 4.0 (Dick Lankes)
Perl on SunOS question (William Wue(2xP)elma(2xN))
perlxstut on Linux 2.0.0 <averste@uni-muenster.de>
Re: Please help me with locking! Using NDBM! (Rex Fowler)
Please Help: "Unresolved external" (DynaLoader) <Jan.Schormann@Informatik.Uni-Oldenburg.DE>
Re: Proper argument processing <tycage@infi.net>
Question: how to query another perl "program" <relkin@bestweb.net>
Re: Recursive sorting (Bart Lateur)
Re: Saving array in Object (Chris Nandor)
Re: Saving array in Object (Andrew M. Langmead)
Re: Trivial(?) readdir question (Steve Monson)
Re: win95 install question <helgek@berlin.snafu.de>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 11 Sep 1997 15:03:03 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: (no subject)
Message-Id: <3417DDF7.7DF8@icl.fi>
Erich Kreiselmaier wrote:
>
> I am new to perl programming. Does anyone have a recommendation for
> free available documentation.
Yes, the free included documentation that comes with
every proper Perl kit.
Start from http://www.perl.com
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: 11 Sep 1997 12:00:01 GMT
From: nigelr@convex.hp.com (Nigel Reed)
Subject: Re: divide by zero problem in reports.
Message-Id: <5v8mg1$qgi$1@news.rsn.hp.com>
Thanks for everyone's advice here and through email, I'll go
and impliment some of your suggestions.
Regards
Nigel
Nigel Reed (nigelr@convex.hp.com) wrote:
> I've come across a problem and I wonder if anyone has a better solution.
> I have a report which basically looks like
> Computer name Hours Available Hours uses Percent used
> @>>>>>>>>>>>> @##### @##### @###.##
> $name,$avail,$used,(($used/avail)*100)
> .
> Now, if I have 0 hours used, I'm getting the following error...
> Illegal division by zero at weekly line 267, <IN> chunk 123.
> main::STDOUT called at weekly line 67
> I could use an extra variable and something like
> if ($used = 0) {
> $percent = 0
> } else {
> $percent = (($used/avail)*100)
> }
> But I could do without the extra 'if' section. Anyone got
> any clever ideas for me please?
> Regards
> Nigel
------------------------------
Date: Thu, 11 Sep 1997 15:08:49 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: flock in Win32?
Message-Id: <3417DF51.48C6@icl.fi>
Cameron Dorey wrote:
>
> Is there any way to simulate/substitute/work around the flock() function
> in Win32 Perl? My understanding is that the function is not there
> because of the differences in the Win and Unix operating systems, but it
> seems that somebody more knowledgable than me (and there are a *bunch*
> of you out there) would have found a solution by now. Unix is not an
> option with the resources available to me at this time. Thanks for any
> guidance (even if it is "no.").
flock() most definitely is "there" on Win32 (at least on
Windows NT).
If it isn't "there" for you (or the Perl release you happen
to have - did you try? ;-), then get a newer release:
The ActiveState/ActiveWare port known as Perl for Win32:
http://www.activestate.com
The "core" Perl release/build for Win32 platforms:
http://www.perl.com
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: Thu, 11 Sep 1997 14:27:59 GMT
From: knetsch@golden.net.no.spam (SJK)
Subject: Re: flock in Win32?
Message-Id: <3417fdcb.6139969@news.golden.net>
On Wed, 10 Sep 1997 13:53:27 -0500, Cameron Dorey <camerond@mail.uca.edu> wrote:
>Good afternoon, Perl hackers,
>
>Is there any way to simulate/substitute/work around the flock() function
>in Win32 Perl? My understanding is that the function is not there
>because of the differences in the Win and Unix operating systems, but it
>seems that somebody more knowledgable than me (and there are a *bunch*
>of you out there) would have found a solution by now. Unix is not an
>option with the resources available to me at this time. Thanks for any
>guidance (even if it is "no.").
>
>Cameron Dorey
>camerond@mail.uca.edu
>
A solution that I've seen involves designing your own basic flock()
What you do is test for a flag file. This file only exists while you are
operating on the data file you wish to work on.
Here's the pseudo code
do loop if exist flagfile.flag # Loop until flagfile is destroyed, basically
endloop # puts the program in a holding pattern
open(FLAGFILE,">flagfile.flag"); # Create flag file
close(FLAGFILE);
open(INFILE,"file you wish to process"); # Open and process data file
process file and close;
unlink("flagfile.flag"); # Destroy flagfile
This should do what you want, 99.9% of the time.
Of course, you can run into problems .1% of the time with two instances of the
program trying to write the flagfile at the same time. So you have a flagfile
for the flagfile. And then you run into problems with two instances of the
program trying to .... and on and on it goes. Have you thought about trying to
write a semaphore??? ;-)
Cheers! and HTH
Stuart Knetsch
Remove the you know what from my address to send me E-mail
------------------------------
Date: 11 Sep 1997 14:05:49 GMT
From: "Helge Kruse" <helgek@berlin.snafu.de>
Subject: Re: Flushing STDOUT?
Message-Id: <01bcbebc$02b3d400$37e0c3c2@hk.bercos.berkom.de>
ckc@dmi.min.dk schrieb im Beitrag <873976943.12036@dejanews.com>...
> A relatively simple question (I presume). I have attempted to find the
> answer in the Camel book, but to no avail. Here goes:
Did you look for $| ?
Helge
------------------------------
Date: Thu, 11 Sep 1997 09:03:55 -0400
From: Phil Barone <pbarone@rsa.hisd.harris.com>
To: Charles DeRykus <ced@bcstec.ca.boeing.com>
Subject: Re: Help on 'system' function
Message-Id: <3417EC3B.21826F4A@rsa.hisd.harris.com>
Charles DeRykus wrote:
>
> In article <01bcad80$7d84b700$6502a713@fce04438.jubilee.ford.com>,
> John Spencer <dhayden@ford.com> wrote:
> > I would be grateful if anyone could help this problem:-
> >
> > First Program first.pl
> > .....
> > system("second.pl",$amount);
> > print "Amount Now =$amount";
> > ......
| >
| >
| >
| > Second Program second.pl
| > ......
| > $input=<STDIN>;
| > $amount = $amount + $input
| > ......
| >
| >
| >
| > The first program "first.pl" should jump to the second program
"second.pl"
| > with $amount as an arguement. It should then take an input amount
and add
| > to $amount and pass back to "first.pl" upon completion of
"second.pl"
| >
| > How to I pass back the new value of $amount????
| >
| > Or is there a better way of doing this?????
| >
| >
|
| Backticks are useful. Here's a possibility which is
| short (often a relief if not a virtue :)
|
| First program:
|
| print "Amount Now = ", `/path/to/second.pl $amount`, "\n";
|
Here's one I use a lot:
my $response;
chop($response = `/path/to/second.pl $amount`);
------------------------------
Date: Thu, 11 Sep 1997 09:35:14 -0400
From: Michael Genovese <mikeg@slpma8.ed.ray.com>
Subject: How to check if a file exits!
Message-Id: <3417F392.546F@slpma8.ed.ray.com>
This is problably a fairly simple question, but I can't
seem to find a "nice" way to do it in perl ...
how do I check to see if a file EXISTS ?
I don't need to read it, but I do need to know if it exists.
--
Mike Genovese, Sr. S/W Engineer
Software Engineering Laboratory, Raytheon, Marlborough, MA
508-490-3891
My opinions are my own, and NOT necessarily those of my employer.
------------------------------
Date: Thu, 11 Sep 1997 16:33:16 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: How to check if a file exits!
Message-Id: <3418012B.41C6@theo.phy.uni-bayreuth.de>
Hi,
Michael Genovese wrote:
>
> This is problably a fairly simple question, but I can't
> seem to find a "nice" way to do it in perl ...
>
> how do I check to see if a file EXISTS ?
>
> I don't need to read it, but I do need to know if it exists.
Take a look at the perlfunc manual page ...
[...] File exists.
^^^^^
Oops ... something is lost during cut-and-paste ... ;-)
(left as an exercise to find out what ...)
Bye, Eike
--
======================================================================
Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
----------------------------------------------------------------------
e-mail -> eike.grote@theo.phy.uni-bayreuth.de
WWW -> http://www.phy.uni-bayreuth.de/theo/tp4/members/grote.html
http://www.phy.uni-bayreuth.de/~btpa25/
======================================================================
------------------------------
Date: Thu, 11 Sep 1997 09:48:36 -0400
From: Isabella Shen <ishen@ciscorp.com>
Subject: How to connect to Oracle database
Message-Id: <3417F6B4.155CA451@ciscorp.com>
Hi,
I don't know how to connect to Oracle database (7.3, SQL*Net 2.3) from
Netscape Enterprise server 2.01 by perl? What is the connect string? I
already installed the client communication software (SQL*Net 2.3) on the
web server. What is the perl syntax for connection?
Thank you very much.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Isabella Shen Tel: (412) 787-9600 ex 125
Email: ishen@ciscorp.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Thu, 11 Sep 1997 09:37:41 -0600
From: brian.hoffman@starkist.com
Subject: how to generate permutations of an array
Message-Id: <873987742.21476@dejanews.com>
I've been mulling over this and can't seem to come up with a good answer.
is there a way to generate every permutation of an array? for example, if
I have an array[0] through array[8], can I manipulate the array in such a
way that it cycles through every 9! permutation? thanks -brian
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 11 Sep 1997 14:25:25 GMT
From: williamw@rooster.igs.deleteTheRooster.net (William Wue(2xP)elma(2xN))
Subject: Re: How to open a file for both read and write
Message-Id: <3417fbf5.3586563@news.igs.net>
On Tue, 9 Sep 1997 23:54:18 GMT, ebohlman@netcom.com (Eric Bohlman)
wrote:
>
>Charlie (charlie@flychina.com) wrote:
>
>
>: Songtao Chen <songtao@nortel.ca> wrote
>: > Could anyone tell me how to open a file for both
>: > read and write ?
>
>: open(FH,"+>filename") || die "Cannot open filename\n";
>
>For some reason, reading this bit of advice has caused an early 1960's
>instrumental by the Surfaris to start playing in my head...
>
I think what he's trying to say is
open(FH,"+>filename")
will destroy any existing file called "filename" and create a new,
empty one in its place.
open(FH,"+<filename")
will open your file without destroying the contents of what is already
there, (but won't work if the file doesn't already exist - so check
first).
Still, better than the book I first tried to learn from which says
"there are tjree versions of open() that are identical. these are +<,
+> and +>>..." Good joke.
-------------------------
William Wue(2xP)elma(2xN)
Reply-To: williamw (at) igs (dot) net
--------------------------------------------------------------
It is pitch black. You are likely to receive spam from a grue.
------------------------------
Date: Thu, 11 Sep 1997 09:55:14 -0500
From: Brett Denner <Brett.W.Denner@lmtas.lmco.com>
Subject: Is there a simpler syntax for: defined $a && $a ne ''
Message-Id: <34180652.41C6@lmtas.lmco.com>
I frequently need to ensure that a scalar contains "something"; i.e.,
that it is defined and that it contains some non-empty value. I usually
try something like this:
$a = 1 unless (defined $a and $a ne '');
Is there a simpler, more concise syntax for the "unless" part of this
expression? I've tried things like:
$a = 1 unless length $a;
and
$a = 1 unless $a =~ /./;
but these don't work unless $a is already defined. Also, I can't just
test for true or false, because '0' is false, but would be acceptable
under my criterion.
I know this is not exactly a matter of earth-shattering importance,
but it would be nice to find a cleaner (shorter) idiom to express this
test.
Thanks,
Brett
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Brett W. Denner Lockheed Martin TAS
Brett.W.Denner@lmtas.lmco.com P.O. Box
748
(817) 935-1144 (voice) Fort Worth, TX 76101
(817) 935-1212 (fax) MZ 9333
------------------------------
Date: Thu, 11 Sep 1997 17:01:54 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Korn Shell to Perl
Message-Id: <341807E2.60F13944@absyss.fr>
Cloves Ferreira Junior wrote:
>
> Hello,
>
> does anyone knows where can I find a perl program to convert korn
> shell scripts to perl 5?
> Thanks in advance,
> Cloves.
I've seen that question before, but I don't remember any positive
answers. Maybe you should check out Deja News and hope for the best.
- doug
------------------------------
Date: Thu, 11 Sep 1997 08:38:38 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Macperl: Selena Sol's Groupware Calendar
Message-Id: <pudge-ya02408000R1109970838380001@news.idt.net>
In article <341693B0.35028710@mcgraw-hill.com>, Ann Harste
<aharste@mcgraw-hill.com> wrote:
# I'm sorry, I was not able to open ./Library/cgi-lib.pl. Would you
# please check to make sure that you gave me a valid filename and that the
# permissions on are set to allow me access?
You need to have cgi-lib.pl installed for MacPerl. Then I would think
you'd have to edit the CGI you are using to find it. Here is the
recommended method (IMO):
* Make a new directory in "lib" or at the same level as "lib". Call it
"site_perl" or something similar.
* Go into the MacPerl Edit:Preferences and add that path to your Libraries.
* Drop cgi-lib.pl in there.
* Change the CGI to point simply to "cgi-lib.pl", not "./Library/cgi-lib.pl".
That should do it ... as Tom P says, Hope that helps!
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
------------------------------
Date: 11 Sep 1997 08:39:28 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Re: make: *** File Makefile' has modification time in the future
Message-Id: <dpvqgja7z.fsf@s3i.com>
klassa@aursgh.aur.alcatel.com (John M. Klassa) writes:
> I've been trying to install some perl modules into one of my own directories
> (as opposed to the system-wide location, which is writable only by our
> sysadmin staff). When I do a "make Makefile.PL ; make" (whether manually or
> through CPAN.pm's shell mode), I get:
>
> make: *** File Makefile' has modification time in the future
>
> I've never seen this before... I know what causes the message to pop out
> (i.e. I know that Makefile has a timestamp that's actually in the future),
> but *why* does Makefile have a timestamp that's in the future? What causes
> this? Anybody else seen this?
>
> Thanks!
> John
>
> --
> John Klassa / Alcatel Telecom / Raleigh, NC, USA
Greetings,
I see this problem all the time. The problem at our location
is that my files are sitting on a computer (called "elmo") and I am
running the processes on the machine sitting in front of me (called
"cox"). When I try to make something I can get the above error.
The root of the problem is that the time is different on the two
computers. elmo thinks that the time is 2:20; cox think that the
time is 2:10. When I edit the makefile, elmo puts the timestamp of
2:20 on it since that is where the file resides. When I run make, it
runs on cox, and the program uses the time of the computer that it is
running on, namely cox, and it says it's 2:10. That confuses "make"
and produces the above error.
Frequently, when I am making a large package I get lots and lots of
these errors. The short term solution is to do an "rdate" to change
the times so they match, but realize that computer clocks drift so
pretty soon you'll have the same problem again and suddenly changing
the time can be "a bad thing" for some programs. The only long term
way to prevent this error is to synchronize the computers using "ntp"
or some other time protocol.
Heres a little program that I use to figure out how the times are
going on my computers. You'll need to change the first line and
change the computer names:
#!/home/dorman/bin/perl -Tw
require 5.002;
use strict;
use Socket;
my $SECS_of_70_YEARS = 2208988800;
sub ctime { scalar localtime(shift) }
my $iaddr = gethostbyname('localhost');
my $proto = getprotobyname('tcp');
my $port = getservbyname('time', 'tcp');
my $paddr = sockaddr_in(0, $iaddr);
my($host);
my( @hostnames )=(
"sherman",
"ike",
"abrams",
"jeb",
"grant",
"bradley",
"blackbird",
"cox",
"bragg",
"elmo");
$| = 1;
printf "%-24s %8s %s\n", "localhost", 0, ctime(time());
foreach $host (@hostnames) {
printf "%-24s ", $host;
my $hisiaddr = inet_aton($host) || die "unknown host";
my $hispaddr = sockaddr_in($port, $hisiaddr);
socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(SOCKET, $hispaddr) || die "bind: $!";
my $rtime = ' ';
read(SOCKET, $rtime, 4);
close(SOCKET);
my $histime = unpack("N", $rtime) - $SECS_of_70_YEARS ;
printf "%8d %s\n", $histime - time, ctime($histime);
}
--
Clark Dorman "Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
------------------------------
Date: Thu, 11 Sep 1997 14:16:42 GMT
From: zachy@nite.org.il (Yoav Zach)
Subject: manipulating chars inside strings?
Message-Id: <3417fa71.27246524@news.netvision.net.il>
Hi,
Can anyone tell me how to manipulate single chars inside
strings, something like 'str[j] = c;' in C?
thanks,
Yoav.
------------------------------
Date: 11 Sep 1997 15:46:34 GMT
From: tony@crux.blackstar.co.uk (Tony Bowden)
Subject: Net::Whois unsetting $/?
Message-Id: <5v93oq$qko$1@sparc.tibus.net>
Whilst using Net::Whois within a while loop that was reading from a file,
I noticed that the while loop seemed to terminate after the first call
to Net::Whois.
I eventually traced this to the fact that Net::Whois is undef-ing
$/, thus the next iteration of the loop was slurping in the remainder
of the file.
Surely it should, upon exit, reset $/ to whatever it was when called?
Tony
--
-----------------------------------------------------------------------------
Tony Bowden | tony@tmtm.com / t.bowden@qub.ac.uk / http://www.tmtm.com/
Belfast, NI | How can you be a nymphomaniac and never had sex? / I'm choosy
-----------------------------------------------------------------------------
------------------------------
Date: Thu, 11 Sep 1997 08:30:36 -0400
From: Daniel Mills <dmills@riag.com>
Subject: PERL 5 for Alpha OpenVMS
Message-Id: <3417E46C.5709@riag.com>
Does anyone know where I can get a reliable port for this OS?
-- TIA - Dan.
=========================================================
Dan Mills
RIAG
dmills@riag.com
---------------------------------------------------------
The opinions expressed here are those of the author only.
Sorry to be so uncreative here but I'm just too busy (or
slow) to do anything about it.
=========================================================
------------------------------
Date: Thu, 11 Sep 1997 08:11:22 -0400
From: macdick@primax.com (Dick Lankes)
Subject: Perl and Nt 4.0
Message-Id: <macdick-1109970811220001@babar.access.one.net>
We are setting up an NT 4.0 server and have need to use Perl for an index
and search capability. We have been using Perl 5 on BSDI Unix with the
index and search (ICE-2) and all works great. Migrating to NT has been a
hassle and we cannot get Perl 5 or the script to work.
Any help would be greatly appreciated!
------------------------------
Date: Thu, 11 Sep 1997 14:25:28 GMT
From: williamw@rooster.igs.deleteTheRooster.net (William Wue(2xP)elma(2xN))
Subject: Perl on SunOS question
Message-Id: <3417fe3d.4170847@news.igs.net>
Okay, I admit it, I use Perl for Win32/95 (I have no choice). Maybe it
has a few peculiarities, but I was trying to copy a script that works
fine on Win95 to a SunOS platform, and I've been getting errors that
seem quite bizarre. For example:
chop($input = <STDIN>);
works just fine, but
chomp($input = <STDIN>);
and
@files = glob($input);
generate syntax errors, though they work fine under Win95 (which makes
them truly exceptional :) ).
Any ideas?
-------------------------
William Wue(2xP)elma(2xN)
Reply-To: williamw (at) igs (dot) net
--------------------------------------------------------------
It is pitch black. You are likely to receive spam from a grue.
------------------------------
Date: 11 Sep 1997 15:17:40 GMT
From: "Michael Averstegge" <averste@uni-muenster.de>
Subject: perlxstut on Linux 2.0.0
Message-Id: <5v922k$u86@majestix.uni-muenster.de>
Hi folks,
the hello-world scripot does mot work, although yust
doing all fine like the first pages of the "perlxstut" manpage.
really not difficult but I get the messages:
hello
perl: './Mytest.o' is not an ELF executable for 386/486
Can't load './Mytest.o' for module Mytest: Not an ELF shared library at /usr/lib/perl5/DynaLoader.pm line 140.
at Mytest.pm line 18
BEGIN failed--compilation aborted at ./hello line 5.
What is wrong?
On Solaris 2.5 same source works fine!
Greetings
Michael
------------------------------
Date: 11 Sep 1997 07:57:49 -0500
From: rmfowler@raptor.mtc.ti.com (Rex Fowler)
Subject: Re: Please help me with locking! Using NDBM!
Message-Id: <5v8psd$ffp@raptor.mtc.ti.com>
In article <5v8ffo$8cl$1@brie.direct.ca>,
Jason Hazzard <hazzard@usa.net> wrote:
>Hello Perlers,
>
> I am using Tie() with NDBM_File, and I am very confused about locking.
I had the same problem/request and didn't receive any responses. There
is no obvious method to lock the open ndbm file since you don't have a
file descriptor. The Berkeley DB DB_File does have a way to do it and
installing berkeley db 1.86 was a painless procedure with the only real
decision was on which version to use. I think the current DB_File (at
the time) was based on db 1.86 so I installed 1.86 instead of 2.0. You
might want to check the development of 2.0 before deciding.
Then check the DB_File doc for an example on FLOCK'ing.
>Just a basic explanation would help me a LOT!
>
>Thanks,
>Jay
--
Rex Fowler http://www.mtc.ti.com/~rmfowler
(972)997-2779 mailto:rmfowler@mtc.ti.com
Alpha Pager http://www.mtc.ti.com/cgi-bin/alpha_pager.cgi
TI MSG rfow
------------------------------
Date: 11 Sep 1997 15:07:33 +0200
From: "Jan Schormann" <Jan.Schormann@Informatik.Uni-Oldenburg.DE>
Subject: Please Help: "Unresolved external" (DynaLoader)
Message-Id: <5v8qeo$8qg@news.Informatik.Uni-Oldenburg.DE>
Greetings,
apart from the automatic mail from gnat this didn't cause any
response yesterday, but I still think you're the only ones who can
possibly help me, so I'm trying with a new subject.
I'm writing a perl extension in C using perlXS, ExtUtils, DynaLoader
and the like, and the C code refers to some self-made library, too.
This is on an HP 715/100 running HP-UX 10.20.
Finally I can start "make test" but get:
| [...]
| PERL_DL_NONLAZY=1 /usr/contrib/bin/perl -I./blib/arch -I./blib/lib -I/opt/perl5/lib/PA-RISC1.1/5.003 -I/opt/perl5/lib test.pl
| 1..7
| Can't load 'blib/arch/auto/Bismas/Bismas.sl' for module Bismas: Unresolved external at /opt/perl5/lib/DynaLoader.pm line 140.
|
| at blib/lib/Bismas.pm line 41
| BEGIN failed--compilation aborted at test.pl line 12.
| not ok 1
(Bismas is the name of my extension)
Is there something obvious missing?
I have linked everything to an executable and it runs happily - I just
can't start it in perl. It does run with perl on my linux at home. So
maybe on hp I have to tell the linker or dynaloader to load some more
libraries?
But - how can I figure out what's missing so I can tell the linker to
add more code to 'blib/arch/auto/bismas/Bismas.sl'? Or could I tell
DynaLoader to load some system libraries in advance so I don't have to
blow up 'blib/arch/auto/bismas/Bismas.sl'?
Well, what does "unresolved external" mean, anyway - maybe I'm
thinking in the wrong direction...
Please help!
Jan.
=o= M-1 0 0 M-x praise-emacs =o=
Jan.Schormann@informatik.uni-oldenburg.de / voice: 0441/777 248
------------------------------
Date: Thu, 11 Sep 1997 09:11:01 -0400
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: Proper argument processing
Message-Id: <3417EDE4.3F0FFCF1@infi.net>
Phil Barone wrote:
>
> I have a few questions about the proper way to get command line
> arguments using Getopt::Std while using strict and diagnostics.
>
> For example:
> ------------------
> #!/usr/local/bin/perl -w
>
> use strict;
> use diagnostics;
>
> use Getopt::Std;
> getopts('f:');
>
> my $InFile = $opt_f if (defined $opt_f);
>
> print "$Infile\n";
> -------------------
> Gives me a "requires explicit package name at line 9" message. I have
> tried defining the options but haven't found a way to get rid of these
> messages other than commenting out use strict and use diagnostic.
>
> Another problem I have is if I do something like:
>
> my $InFile = $opt_f;
>
> then I am only using $opt_f once, so I get the you might have had a Typo
> messages.
> How do people handle this situation?
The
use strict;
is causing the "problem"
You need to add a
use vars qw($opt_f);
use vars lets you predeclare global variable names in a script.
This will get rid of the use strict errors and the typo warnings
as well, if I remember properly.
Hope this helps,
Ty
+---+
Ty Cage Warren tycage@infi.net
Systems Engineer InfiNet
Homepage: http://tazer.engrs.infi.net/~tycage
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78 B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------
------------------------------
Date: Thu, 11 Sep 1997 10:42:22 -0400
From: Vijay Venugopal <relkin@bestweb.net>
Subject: Question: how to query another perl "program"
Message-Id: <3418034E.2781@bestweb.net>
Hi,
I looked through the FAQ quickly and didn't see anything that approaches
this situation. I have a file that contains a series of perl hashes.
Something like:
$customer_name{"cust1"} = "John Smith";
$cust_address{"cust1"} = "Info here";
$cust_info{"cust1"} = "More info here";
$customer_name{"cust2"} = "Mary Riley";
$cust_address{"cust2"} = "Yet More Info here";
$cust_info{"cust2"} = "Even More info here";
This file is then required by a series of other programs that use the
information contained in it.
Now I'm writing a new program that will only need 2 lines out of all the
declarations included in the above file. The 2 lines will be the values
of two hashes for a variable customer. That is to say each invocation
of the program will need to get a different two lines. I can think of
two ways of extracting this information.
1) require the file. Then all the declarations will be available. This
seems inefficient because there are a LOT of entries in each hash.
2) read each line, match on the key (ie. cust1 or cust2) and eval any
lines that match this file. This just seems like a lot of work to
accomplish what I need to do.
So my question is this: Is there a better or more efficient way of
extracting the information I need?
I can't change the format of the file containing the delcarations as
it's used by several other programs. Any suggestions?
thanks
Vijay
------------------------------
Date: Thu, 11 Sep 1997 12:36:55 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Recursive sorting
Message-Id: <341fbb86.7360059@news.tornado.be>
snapfisher@worldnet.att.net (Paul Fisher) wrote:
>I have a gouup of strings of the form xxxxx.#:xxxxx.#:xxxxx.#
>where xxx are alphabetic characters and # is an ascii numerical
>representation (i.e. a number).
>
>I wrote a sort subroutine to be used by the sort function, as in "sort
>by_myfunc()". This routine breaks off the first chunnk of the string and
>evaluates it. If the two substrings are equal, I want it to recursively
>call itself with the remaining string portions.
You don't need recursion. Use a loop instead. Something like
sub my_func {
my($a, $b) = ($a,$b);
# don't touch the original variables!
my($a1,$b1,$comp);
while($a or $b) {
($a1,$a)=split('#',$a,2);
($b1,$b)=split('#',$b,2);
$comp=($a1 cmp $b1) and return $comp;
}
}
I haven't tested it, but you catch my drift, I guess.
HTH,
Bart.
------------------------------
Date: Thu, 11 Sep 1997 08:41:26 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Saving array in Object
Message-Id: <pudge-ya02408000R1109970841260001@news.idt.net>
In article <34182208.FD540C03@inf.ethz.ch>, Per Kistler
<kistler@inf.ethz.ch> wrote:
# How do I save an array within an object? If I do:
# $self->{'data'} = \@myarray;
# then I loose the contents of myarray after the method
# returns. Of course I could return the array and save
# it from above like:
# @arr = $obj->someMethod();
# but I'd like to have the array withing the object for
# further use.
$self->{'data'} = [@myarray];
This returns a reference to the CONTENTS of @myarray (by creating an
anonymous array), rather than a reference to the array itself.
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
------------------------------
Date: Thu, 11 Sep 1997 14:04:47 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Saving array in Object
Message-Id: <EGCKG0.8yw@world.std.com>
Per Kistler <kistler@inf.ethz.ch> writes:
>How do I save an array within an object? If I do:
>$self->{'data'} = \@myarray;
>then I loose the contents of myarray after the method
>returns.
Since your object is really just a blessed hash, the information in
perllol (perl lists of lists) and perldsc (perl data structure
cookbook) man pages would be of use. Escpecially the warnings against
using the "\" operator. How about if you use the anonymous array
constructor.
$self->{'data'} = [ @myarray ];
That way, you get a new array reference each time.
--
Andrew Langmead
------------------------------
Date: 9 Sep 1997 08:41:57 -0500
From: smonson@tri.sbc.com (Steve Monson)
Subject: Re: Trivial(?) readdir question
Message-Id: <5v3jn5$7if@euphony.tri.sbc.com>
>>> > How likely is readdir to NOT return '.' and '..' as the first two
>>> > directory entries when reading in a directory?
>Marc Philips <Marc.Philips@tvd.be> wrote:
>>On UNIX, a directory is created with two (sub)directory entries: "." and
>>"..".
>>
>>Given that readdir reads the directory sequentially, I'd say that they
>>will always be the first two entries returned and always in that order.
M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
>That isn't defined. So only a masochist would assume it.
True enough, in a sense. When I first started playing around with
Unix many moons ago, I wanted to create a directory, and did a system
call to do it. I got my directory, but that was all. I couldn't
refer to "." or ".." because I didn't create them. I tried a few things,
and then finally looked up the code for mkdir. As soon as the directory
is created, links for "." and ".." are established.
So, mjtg is correct, in that this sequence is not defined, and there
might well exist directories without "." and ".." but I think you can
feel pretty confident that the vast majority of directories in
existence will have been created with "mkdir" and will have these two
subdirectories at the front of the list, never to be removed. (You can,
indeed delete "." and ".." but you'll have to work a bit to get them
back. So don't do it.)
The @dirs = grep(/^\.\.?$/) solution is a good one in any case.
Steve Monson
--
"How could you be so self-centered?
Especially as we are supposed to be talking about me."
------------------------------
Date: 11 Sep 1997 14:10:27 GMT
From: "Helge Kruse" <helgek@berlin.snafu.de>
Subject: Re: win95 install question
Message-Id: <01bcbebc$a86bd6e0$37e0c3c2@hk.bercos.berkom.de>
Martien Verbruggen <mgjv@mali.comdyn.com.au> schrieb im Beitrag
<5v845m$os6$3@comdyn.comdyn.com.au>...
> In article <3416B08D.76FD7273@allmed.net>,
> Holly Sample <holiday@allmed.net> writes:
> If you want to test CGI scripts on your local machine, you will also need
to
> install a local web server. There are a few available, with installation
> instructions from the web (try www.windows95.com). I wouldn't know which
ones
> are good or bad.
I tried the Personal Web Server for Windows 95.
It's easy to install for English Windows installation, but you can make it
run
on other systems like my German too. I added the perl.exe as a CGI program,
and
it works.
Helge
------------------------------
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 1011
**************************************