[11046] in Perl-Users-Digest
Perl-Users Digest, Issue: 4646 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 13 23:17:15 1999
Date: Wed, 13 Jan 99 20:00:20 -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 Wed, 13 Jan 1999 Volume: 8 Number: 4646
Today's topics:
Re: @ARGV and $_ Question <rafiqmateen@netscape.net>
Re: @ARGV and $_ Question (Andre L.)
Re: __DATA__ <eugene@snailgem.org>
Re: bug? reference to array - first element empty? bug? (Sean McAfee)
Re: bug? reference to array - first element empty? bug? (Andre L.)
Can I use perl with https? <circuit@seanet.com.nospam>
Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus <wschmidt@tyler.net>
Re: Converting numbers to binary in Perl? kirk@kaybee.org
determine, if file is directory (Patrick Clauberg)
Re: determine, if file is directory (Andre L.)
Re: determine, if file is directory <eugene@snailgem.org>
Re: Email notification <akira@usp.br>
Re: Email notification (brian d foy)
Re: Help needed with locking <eugene@snailgem.org>
how do I fork a subroutine in perl ceison@lis.net.au
Installation error krish_v@my-dejanews.com
Re: Perl Criticism <mds-resource@mediaone.net>
Re: Perl Criticism <mds-resource@mediaone.net>
perl on NT forking problem <garth.cunningham@nz.eds.com>
Problem: Configure: shmat's returntype/prototype (Schipmolder, Jan B)
Re: Simple Question lists of lists - please help!! <allan@due.net>
Re: split question (Andre L.)
Re: split question (Andre L.)
Unix-domain TCP sockets (Erik)
Re: Year 2038 problem <sfarrell@farrell.org>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 13 Jan 1999 20:57:25 -0500
From: Rafiq Mateen <rafiqmateen@netscape.net>
Subject: Re: @ARGV and $_ Question
Message-Id: <369D4F05.2B3B10B3@netscape.net>
This is a multi-part message in MIME format.
--------------F92FC23E7359E0AEDAA50A97
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Brad wrote:
>
> Could someone give me a good definition of these two items and a couple good
> examples? Or point me in the direction where I can find good definition and
> examples.
>
> I do know that @ARGV is a Global Variable (array) in Perl which stores
> command line parameters, but what does that mean?
>
> But that $_ is just a mystery to me.
>
> Thanks for your helps
>
> Brad
I will answer the $_ answer for you and hopefully I make sense.
#! perl -w
@one = (1, 2, 3, 4, 5);
There are two ways I usually write the next step:
foreach $i(@one){ }
for($i = 0; $i <= $#one; $i++) { }
I learned using this step is faster:
for(@one)
{
$total = $total + $_; Now the $_ contains the first value in @one
}
As the loop iterates $_ contains 1, 2, 3, 4, 5 respectively.
One more shortcut you may already know let's say you just wanted to
print the numbers you could have just said:
for(@one)
{
print;
# or
print "\n";
}
The numbers or values in your array will print out. Gotta love PERL.
Happy Perling.
--------------F92FC23E7359E0AEDAA50A97
Content-Type: text/x-vcard; charset=us-ascii;
name="rafiqmateen.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Rafiq Mateen
Content-Disposition: attachment;
filename="rafiqmateen.vcf"
begin:vcard
n:Maten;Rafiq
x-mozilla-html:FALSE
org:USAF
adr:;;;;;;
version:2.1
email;internet:rafiqmateen@netscape.net
title:Computer Programmer
x-mozilla-cpt:;-20624
fn:Rafiq Maten
end:vcard
--------------F92FC23E7359E0AEDAA50A97--
------------------------------
Date: Wed, 13 Jan 1999 21:58:57 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: @ARGV and $_ Question
Message-Id: <alecler-1301992158570001@dialup-459.hip.cam.org>
In article <77j8bf$kgg$1@news.monad.net>, "Brad" <roclimb@yahoo.com> wrote:
> Could someone give me a good definition of these two items and a couple good
> examples? Or point me in the direction where I can find good definition and
> examples.
How about... the documentation? :)
Andre
------------------------------
Date: Wed, 13 Jan 1999 22:34:01 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
To: om7@cyberdude.com
Subject: Re: __DATA__
Message-Id: <369D65A9.E1DA44FE@snailgem.org>
You'll mostly use the DATA filehandle (combined with the __END__ token): it
lets you have the data in your program file (instead of reading it from a
separate file). This comes in handy when you want to test out things, since you
can easily modify the input.
This script, for ex., finds the first 10 words in each line of input:
--------------------------
#!/usr/local/bin/perl -w
use diagnostics;
while (<DATA>) {
@words = split (/\W/);
print "@words[0..9]\n";
}
__END__
The DVA XPress Plus allows a PC-based system to switch, control, digitize,
store, record, and play back
video. It also protects the investment into previous systems by using most of
the existing cameras, ca
bles, and monitors.
The product accepts video from up to eight cameras (color or monochrome, NTCS,
or PAL), switches betwee
n the cameras quickly, and compresses the video images and records them to the
computer's hard drive or
other digital storage media without rolling.
------------------------------
om7@cyberdude.com wrote:
> Can someone please tell me where to find out more about __DATA__ and how and
> when to use it. I've tried looking in Programming Perl, but didn't find much
> help there with regards to how and what to use it for and I don't have access
> to the man pages.
>
> Thanks.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 14 Jan 1999 00:28:35 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: bug? reference to array - first element empty? bug?
Message-Id: <TSan2.2001$Ge3.9506010@news.itd.umich.edu>
In article <77j8lg$jpm$1@nnrp1.dejanews.com>, <otis@my-dejanews.com> wrote:
>I'm not sure if this is normal perl behaviour or not. I can't find it in docs.
>What I noticed is that if I return a reference to an array from a subroutine,
>and then go through the array after the call to that subroutine, the very
>first element of the array reference that was returned is always empty. Is
>this normal?
No; the problem is in your code.
>Example:
>my @array = undef;
This is the problem line. "undef" is a scalar value, and assigning a
scalar to an array clears the array and sets its first element to the
scalar. "my @array = undef" is equivalent to "my @array = (undef)".
Solution: Say "my @array = ( );" or even just "my @array;".
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Wed, 13 Jan 1999 21:45:39 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: bug? reference to array - first element empty? bug?
Message-Id: <alecler-1301992145390001@dialup-459.hip.cam.org>
In article <77j8lg$jpm$1@nnrp1.dejanews.com>, otis@my-dejanews.com wrote:
> Example:
> my @array = undef;
> sub foo
> {
> foreach (0 .. 9) { push (@array, $_); } return \@array; }
> }
>
> $refArray = &foo;
>
> foreach $bar (@$refArray)
> {
> print "BAR: $bar\n";
> }
>
> The first $bar will be empty ("").
Works for me:
sub foo { [0..9] }
my $bar = foo;
foreach (@$bar) { print "BAR: $_\n" }
To answer your question, consider this:
@array = undef;
print scalar @array;
Q: Why does this print "1"? Find the answer and you'll understand what you
did wrong.
HTH,
Andre
------------------------------
Date: Wed, 13 Jan 1999 19:24:42 -0500
From: "allen snook" <circuit@seanet.com.nospam>
Subject: Can I use perl with https?
Message-Id: <77jo8d$3td@q.seanet.com>
Hi all,
I'm in the process of putting together a secure perl script, but I want the
script to be run in an encrypted mode. In my HTML that kicks off the
script, I have a form call as follows:
<FORM ACTION="https://www.charm.net/~seattle/cgi-bin/ss.pl" METHOD=POST>
When I click on ye olde submit button, I get the following error
Method Not Allowed
The requested method POST is not allowed for the URL /~seattle/cgi-bin/ss.pl
The permissions on the file are 755, of course. If I replace the https with
http, it works fine, but obviously it is no longer secure.
Is this a problem with my ISP, or perl? My ISP hasn't answered my question
yet.
Thanks
...Allen
circuit@seanet.com.nospam
------------------------------
Date: Wed, 13 Jan 1999 20:31:45 -0600
From: WWS <wschmidt@tyler.net>
Subject: Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <369D5710.9DDBA57E@tyler.net>
You know what John Lennon would say about all this if he were
alive right now??? He would say:
AAAGHH!!!! HELP!!! I'M IN A BOX SIX FEET UNDERGROUND!!!
LET ME OUT!!!!!!
--
<*>
__________________________________________________WWS_____________
------------------------------
Date: 14 Jan 1999 03:30:56 GMT
From: kirk@kaybee.org
Subject: Re: Converting numbers to binary in Perl?
Message-Id: <77jodg$3dh$2@news-int.gatech.edu>
M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
: $BinaryValue = chr $IncomingNumber; or
Thank you... it worked great...
--
Kirk Bauer -- Georgia Tech -- kirk@kaybee.org <== Finger for PGP
http://www.kaybee.org/~kirk ResNet RTA Computer Engineering
GT Sport Parachuting Club! http://cyberbuzz.gatech.edu/skydive
------------------------------
Date: Thu, 14 Jan 1999 00:44:08 GMT
From: pat@uni.de (Patrick Clauberg)
Subject: determine, if file is directory
Message-Id: <369d3cdb.31341568@129.217.240.1>
Hi folks,
i would like to do a recursive search over a directory.
Has readdir() a parameter to execute it recursively?
I would like to check every file in the direcory, and if any file is a
directory itself, I start the check function with the new path.
A Perl Book tells me: if (-d $filename) { ....
should work.
Another one is the stat function.
Both of them don't seem to work
how can it be?
I have a perl 5.004 on a Linux 2.0.33 machine
Thanx
Patrick
------------------------------
Date: Wed, 13 Jan 1999 20:18:04 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: determine, if file is directory
Message-Id: <alecler-1301992018040001@dialup-459.hip.cam.org>
In article <369d3cdb.31341568@129.217.240.1>, pat@uni.de (Patrick
Clauberg) wrote:
> i would like to do a recursive search over a directory.
> Has readdir() a parameter to execute it recursively?
>
> I would like to check every file in the direcory, and if any file is a
> directory itself, I start the check function with the new path.
Take a look at the File::Find module. It's very handy.
Andre
------------------------------
Date: Wed, 13 Jan 1999 22:42:57 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
Subject: Re: determine, if file is directory
Message-Id: <369D67C0.C74AF05@snailgem.org>
What's the code look like?
Patrick Clauberg wrote:
> Hi folks,
>
> i would like to do a recursive search over a directory.
> Has readdir() a parameter to execute it recursively?
>
> I would like to check every file in the direcory, and if any file is a
> directory itself, I start the check function with the new path.
>
> A Perl Book tells me: if (-d $filename) { ....
>
> should work.
>
> Another one is the stat function.
>
> Both of them don't seem to work
>
> how can it be?
>
> I have a perl 5.004 on a Linux 2.0.33 machine
>
> Thanx
>
> Patrick
------------------------------
Date: Wed, 13 Jan 1999 10:59:48 -0200
From: Aurelio Akira Mello Matsui <akira@usp.br>
To: Stephan Slagter <sslagter@eega.nl>
Subject: Re: Email notification
Message-Id: <Pine.GSO.3.95q.990113105640.6448A-100000@swan2>
This is impossible to do whith JavaScript. You will need to use CGI!
When administering your system, each time you delete a HTML, you will have
to run a CGI that sends e-mail to your visitors.
Akira.
On Wed, 13 Jan 1999, Stephan Slagter wrote:
> Hello,
>
> I'm looking for a way to send visitors a email notifications when a html
> page is changed on our server. I've seens this before but can't find it
> again.
>
> If you know of any service, perl- or javascript that can do this, please
> let me know.
>
> Any help is welcome
>
> Stephan
>
>
> --
> ----------------------------------------------------------------
> EEGA Ergonomie
> Oude Almeloseweg 78
> 7622 CZ Borne
> Telefoon : 074 - 2668555
> Fax : 074 - 2668595
> Stephan Slagter sslagter@eega.nl
> ----------------------------------------------------------------
>
>
>
>
------------------------------
Date: Wed, 13 Jan 1999 19:43:20 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Email notification
Message-Id: <comdog-ya02408000R1301991943200001@news.panix.com>
In article <Pine.GSO.3.95q.990113105640.6448A-100000@swan2>, Aurelio Akira Mello Matsui <akira@usp.br> posted:
> On Wed, 13 Jan 1999, Stephan Slagter wrote:
> > I'm looking for a way to send visitors a email notifications when a html
> > page is changed on our server. I've seens this before but can't find it
> > again.
> When administering your system, each time you delete a HTML, you will have
> to run a CGI that sends e-mail to your visitors.
this is not a job for CGI. a program which is run periodically should
be sufficient. that way, you don't even have to remember to run the
program :)
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Wed, 13 Jan 1999 22:17:22 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
Subject: Re: Help needed with locking
Message-Id: <369D61C2.C4735A15@snailgem.org>
Jonathan Feinberg wrote:
> info@gadnet.com writes:
>
> > I'm fairly new to perl and would like some advice on file locking.
>
> See perlfaq5.
>
Just out of curiosity, I went to the place you recommended:
http://language.perl.com/newdocs/pod/perlfaq5.html#How_can_I_lock_a_file_
This pointed to flock in the perldoc:
http://language.perl.com/newdocs/pod/perlfunc/flock.html
which has the old, wrong example from the Camel book: the mailbox
appender for BSD that uses
flock(MBOX,LOCK_UN);
instead of
close MBOX;
(wasn't it you who said "never, never, never" a short while ago?).
------------------------------
Date: Thu, 14 Jan 1999 02:31:03 GMT
From: ceison@lis.net.au
Subject: how do I fork a subroutine in perl
Message-Id: <77jkt8$uk2$1@nnrp1.dejanews.com>
Hi, I am writing a perl script that connects to a server and answers requests
from that server. However I am having a problem where perl is buffering the
requests while dealing with 1 request at a time.
I was wondering if there is a way to fork a subroutine in perl allowing it to
use the same port as the main script.
The only forking example I have found is to do with servers in the perlipc
doc, but I need a client to fork its subroutines so that each request from
the server is delt with there and then without being buffered by perl.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 14 Jan 1999 03:34:22 GMT
From: krish_v@my-dejanews.com
Subject: Installation error
Message-Id: <77jojt$1ld$1@nnrp1.dejanews.com>
When I install Perl on AIX 4.2,
make
....
AutoSplitting perl library
Making DynaLoader (static)
The Unsupported function umask function is unimplemented at
../../lib/ExtUtils/Install.pm line 247.
make: The error code from the last command is 2.
Line 247 is:
my $umask = umask 0022 unless $Is_VMS;
which umask
/usr/bin/umask
Any help will be appreciated.
Thank you,
Krish
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 13 Jan 1999 19:01:09 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Perl Criticism
Message-Id: <369D41D5.5C2911C4@mediaone.net>
topmind@technologist.com wrote:
>
> In article <369ABB34.16E5B504@mediaone.net>,
> "Michael D. Schleif" <mds-resource@mediaone.net> wrote:
> > topmind@technologist.com wrote:
> > >
> > > "There is a saying in the Unix community that one should not prevent idiots
> > > from abusing something because it may prevent someone else from making good
> > > use of it. In other words, give everyone chain-saws because (hopefully) more
> > > people will build useful things than the number who will damage something or
> > > someone.
> >
> > In other words, let's take automobiles away until such time as somebody
> > invents one that won't kill so many people on our highways?
> >
> > You seem to miss the point of many here: We make very good use of Perl.
> > Many of us here who have participated in this thread are living better
> > today than ever -- and Perl, the status quo and its dialectic,
> > evolutionary path, has contributed to that.
>
> Are you judging Perl by its ability to project your job by
> being too hard for a new programmer to figure out?
> If that *is* the criteria, then you are right.
OK, I won't presume to speak for anybody but myself, but I choose Perl,
for those tasks I code in Perl, because, using Perl, I meet and exceed
my clients' expectations in the shortest order. That also gives me more
time to transfer knowledge and technology to their payroll personnel,
*none* of whom have even once objected to maintaining my code.
Remember, my clientele are Fortune 100 companies and, in so doing, not
only do *all* of my clients return to request *more* of my service, but
I have been making a quite comfortable six-figure income for several
years. Although, I will be the first to admit that my code *is not*
perfect, I am thankful for TIMTOWTDI and those who come after me can
modify it to future requirements, also in short order.
That is *not* to say that my client's can recruit anybody off of the
street to maintain that which I've set in motion, but I'm unaware of any
language with different entry-level criteria. If I meet and exceed
expectations, including functionality, overall performance and project
deadlines, I feel that I've done a commendable job, including tool
selection. That somebody may come along and *not* find my code
maintainable is quite likely; but, I am confident, with my years of
experience, that enough good Perl coders are available and my clients
continue to pay me and ask me to return. What have I done wrong, mr.
topmind?
> > What else can we do? Do you begrudge us our success ???
Why do you *not* respond to my last line in that other post? Who owes
it to _you_ to make the code suit your criteria, when so many weave
magic with it as it now is? Why should we scrap what works so well for
so many? Who are you to ask us to change something, when you cannot
even qualify as my apprentice?
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: Wed, 13 Jan 1999 19:23:33 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Perl Criticism
Message-Id: <369D4715.F5246022@mediaone.net>
topmind@technologist.com wrote:
>
> Think like a manager. They do not want to risk being stuck with
> cryptic code that takes the follow-on guy or guydette 1 hour
> per line to reverse engineer.
>
> Suppose you owned a business where a programmer spent 4 years
> building all the software. The programmer suddendly quits
> and you hire a new Perl expert. The Perl expert inspects the
> code and realize that the system is composed of 30,000 lines
> of code that looks something like this:
>
> perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
> $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
> $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'
> '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
> $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
> $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'
> '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
> $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
> $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'
> '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
> $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
> $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'
>
> Of course this is an extreme example, but it happens on this and
> smaller scales all the time.
Please, mr. topmind, take this over abundance of energy and go into the
workplace for a few years. You'd do best to stay nowhere longer than
six months, and after five years let's have this conversation again.
I don't think that you truly understand what you've said above.
A couple of years ago, I spent several month long stints at one of
today's top five telecommunications companies. They had a mission
critical application running on a massive Sun server, with many CPU's, a
couple gigs of RAM and interfacing with several terabytes of DASD.
While I was onsite, on a totally different project, there came a
tremendous commotion about that application: the server had been in ill
health for quite sometime, and growing sicker by the day. They were
desperate about that application, but dared *not* shut it down because
they didn't know if they could bring it back up!
That proprietary application had been written for them several years
prior. Compiled code of same ilk -- they didn't even know in what
language it was written. The author and source were nowhere to be
found.
That server had an *uptime* greater than one thousand (1000) days!
No matter how dreadful my Perl code, *how* could _I_ place any
Enterprise in that kind of jeopardy? At least, with your example above,
somebody can always:
my $tmp =
'$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"';
$tmp =~ s/;/;\n/g;
print $tmp, "\n";
What do you think? How many hours is that?
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: Thu, 14 Jan 1999 16:13:34 +1300
From: "Garth Cunningham" <garth.cunningham@nz.eds.com>
Subject: perl on NT forking problem
Message-Id: <77jn6v$n3a$1@news.ses.cio.eds.com>
I have a perl script which runs fine on our unix system but when trying to
run it on an NT system I get the following error.
The name specified is not recognised as an internal or external command,
operable program or batch file.
I run it on NT by doing a
perl program.pl
The program is as follows
#!/usr/local/bin/perl
print "Hi THERE\n";
my $pid = open ( INFILES, "|-" );
unless ( defined $pid ) {
print "Cannot fork \n" ;
}
if ( $pid ){
print "Parent Process\n";
print INFILES "HELLO\n";
print INFILES "WORLD\n";
} else {
print "Child Process\n";
while (<STDIN>) {
print $_;
}
}
It prints out HI THERE and Parent process before printing the error.
Any ideas
Thanks
Garth
garth.cunningham@nz.eds.com
2 Pacific Rise
Mt. Wellington
Auckland
New Zealand
Ph 64 9 5741864
------------------------------
Date: Wed, 13 Jan 1999 16:09:33 -0800
From: jan.b.schipmolder@lmco.com (Schipmolder, Jan B)
Subject: Problem: Configure: shmat's returntype/prototype
Message-Id: <jan.b.schipmolder-ya02408000R1301991609330001@svlnews.lmms.lmco.com>
While attempting to compile perl5.005_02 on my system, I had trouble
with Configure's ability to deal with the presence and form of the
prototype for shmat. I believe I overcame the problems, and here are
some notes for the benefit of whomever. Dare I hope that the Configure
developers will take a look at this?
----- doesn't know that system has shmat prototype -----
My system has a prototype for shmat in /usr/include/sys/shm.h, namely:
extern void *shmat(int, void *, int);
However, Configure, running in default mode (except for -Dprefix),
seems to think otherwise. Here is the output from grep shmat
config.sh:
d_shmat='define'
d_shmatprototype='undef'
shmattype='char *'
So, I ran Configure with -Dd_shmatprototype and that changed the
mentioned grep output to
d_shmat='define'
d_shmatprototype='define'
shmattype='char *'
config_args='-Dprefix=/ufs/sgi534/uf2/perl/perl5.005_02
-Dd_shmatprototype -des
config_arg2='-Dd_shmatprototype'
----- doesn't compute shmat's return type correctly -----
The return type of shmat on my system is void*, but as you can see
from the previous grep output, Configure seems to think it is char*.
So, I ran Configure with the additional option -Dshmattype='void*' (is
that how it's done?) and grep shmat config.sh now produced this:
d_shmat='define'
d_shmatprototype='define'
shmattype='char *'
config_args='-Dprefix=/ufs/sgi534/uf2/perl/perl5.005_02
-Dd_shmatprototype -Dshmattype=void* -des
config_arg2='-Dd_shmatprototype'
config_arg3='-Dshmattype=void*'
which still looks funny (see the first line containing shmattype). In
fact, the non-comment output from grep -i shmat config.h looks like
#define Shmat_t char * /**/
#define HAS_SHMAT_PROTOTYPE /**/
which shows that Shmat_t is still defined as char*. Also, the
Configure output had the following lines:
shmat() found.
and it returns (char *).
*** WHOA THERE!!! ***
The recommended value for $d_shmatprototype on this machine was "define"!
Keep the recommended value? [y]
which confused me some.
So, I figured I had no alternative but modifying config.sh, which I
did with
mv config.sh config.sh.old
sed -e 's/^shmattype.*/shmattype='"'"'void *'"'"'/' config.sh.old > config.sh
(know a better way?) and then I ran
sh Configure -S
make depend
make
make test
make install
without any further trouble.
----- note
All 57 IRIX 5 and 6 machines in our department have the same prototype
for shmat in the same location (see above).
----- note
The output from myconfig is as follows:
-----beginoutput-----
Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
Platform:
osname=irix, osvers=5, archname=IP22-irix
uname='irix sgi534 5.3 12201932 ip22 mips '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='cc', optimize='-O', gccversion=
cppflags='-D_POSIX_SOURCE -ansiposix -D_BSD_TYPES
-I/usr/local/include -DLANGUAGE_C'
ccflags ='-D_POSIX_SOURCE -ansiposix -D_BSD_TYPES -Olimit 4000
-I/usr/local/include -DLANGUAGE_C'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='ld', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib /lib
libs=-lmalloc -lsun -lm -lc -lcrypt -lbsd -lPW
libc=/usr/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-KPIC', lddlflags='-shared -L/usr/local/lib'
-----endoutput-----
----- note
Output from uname -h is
IRIX sgi534 5.3 12201932 IP22 mips
----- note
Output from /bin/hinv is
Iris Audio Processor: version A2 revision 1.1.0
1 250 MHZ IP22 Processor
FPU: MIPS R4010 Floating Point Chip Revision: 0.0
CPU: MIPS R4400 Processor Chip Revision: 6.0
On-board serial ports: 2
On-board bi-directional parallel port
Data cache size: 16 Kbytes
Instruction cache size: 16 Kbytes
Secondary unified instruction/data cache size: 2 Mbytes
Main memory size: 160 Mbytes
EISA bus: adapter 0
Integral Ethernet: ec0, version 1
Integral SCSI controller 1: Version WD33C93B, revision D
Integral SCSI controller 0: Version WD33C93B, revision D
Disk drive: unit 2 on SCSI controller 0
Disk drive: unit 1 on SCSI controller 0
Graphics board: Solid Impact
----- note
I'm keeping a copy of this file. If it makes it easier, I can uuencode
it and email it.
--
jan.b.schipmolder@lmco.com
------------------------------
Date: 14 Jan 1999 02:11:38 GMT
From: "Allan M. Due" <allan@due.net>
Subject: Re: Simple Question lists of lists - please help!!
Message-Id: <77jjoq$m5k$0@206.165.165.163>
Dave Underwood wrote in message <369bf227.32562170@news.vanderbilt.edu>...
:I'm trying to do something really simple but can't. I have a standard
:txt file that when builds looks like: (pipe delimited)
:a1|a2|a3|a4
:aa1|aa2|aa3|aa4
:aaa1|aaa2|aaa3|aaa4
:what i need to do is have a script produce an html page which will
:output the data as:
:"Column One:"
:a1
:aa1
:aaa1
:"Column Two:"
:a2
:aa2
:aaa2
[snip]
Just in the mood. I am sure there is a way to use map here, but the ones that
came to mind were called in a void context and I don't want to start down that
slippery slope.
HTH
AmD
#!/usr/local/bin/perl -w
use strict;
my ($i,$j,@LoL);
my @array = qw(a1|a2|a3|a4 aa1|aa2|aa3|aa4 aaa1|aaa2|aaa3|aaa4);
foreach (@array) {
$i = 0;
foreach (split (/\|/,$_)){
push @{$LoL[$i]},$_;
$i++;
}
}
for $i (0 .. $#LoL) {
print "\ncolumn ",$i+1,"\n";
for $j ( 0 .. $#{ $LoL[$i] } ) {
print "$LoL[$i][$j]\n";
}
}
------------------------------
Date: Wed, 13 Jan 1999 20:57:36 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: split question
Message-Id: <alecler-1301992057360001@dialup-459.hip.cam.org>
In article <Pine.SOL.3.96.990113160519.28504A-100000@ux5.cso.uiuc.edu>,
Bryan Camp <b-camp@students.uiuc.edu> wrote:
> I'm having a problem using the split command.
> I have a file with the following format:
>
> SRC1=A510I52616300 AMP|52453
>
> I want the output of this line to look like this:
>
> SRC1=A510I52616300_52453|AMP
Why split when you can substitute?
$_ = 'SRC1=A510I52616300 AMP|52453';
s/(.*)\s+(.*)\|(.*)/$1_$3|$2/g;
print;
# SRC1=A510I52616300_52453|AMP
HTH,
Andre
------------------------------
Date: Wed, 13 Jan 1999 21:01:01 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: split question
Message-Id: <alecler-1301992101010001@dialup-459.hip.cam.org>
In article <alecler-1301992057360001@dialup-459.hip.cam.org>, I wrote:
> s/(.*)\s+(.*)\|(.*)/$1_$3|$2/g;
Duh. No /g needed here.
s/(.*)\s+(.*)\|(.*)/$1_$3|$2/;
Andre
------------------------------
Date: 14 Jan 1999 02:22:40 GMT
From: eln@cyberhighway.net (Erik)
Subject: Unix-domain TCP sockets
Message-Id: <77jkdg$so4$1@news.cyberhighway.net>
I've been working on putting up a mail-parsing engine which in
turn talks to a database server. In order to make things a bit more
efficient, I thought putting up a daemon on the client side that is
constantly connected to the daemon on the database server would be a neat
idea. So, each time the mail parser is run, it just opens up a unix-domain
socket to this daemon process, and the daemon sort of acts as a relay.
This reasoning is also due in part to the fact that the socket between
the client and the database server is encrypted, and loading up encryption
modules every time mail arrives takes a lot of time.
Anyway, I haven't done anything with unix sockets before, and I'm stuck at
the very beginning. I took the client-server code pretty much straight from
perldoc perlipc, and did minor modifications to it.
The problem is, when I call the client program, exactly half the time I
get no output on either side: No error message, no nothing.
So, if I were to execute the client 10 times in a row, it would work fine
on tries 1, 3, 5, 7, and 9, but fail on tries 2, 4, 6, 8, and 10.
This seems exceedingly bizarre to me.
I'm using perl 5.005_02 on a Linux 2.0.33 system with libc5.3.12-3.
--server side---
#!/usr/bin/perl
use Socket;
use Carp;
sub spawn;
sub REAPER;
my $NAME = "/usr/ch/data/dreg-socket";
my $uaddr = sockaddr_un($NAME);
my $proto = getprotobyname('tcp');
socket(SERVER,PF_UNIX,SOCK_STREAM,0) || die "Unix-domain socket: $!";
unlink($NAME);
bind(SERVER,$uaddr) || die "Unix-domain bind: $!";
listen(SERVER,SOMAXCONN) || die "Unix-domain listen: $!";
print "Server started on $NAME\n";
$SIG{CHLD} = \&REAPER;
for($waitedpid = 0;
accept(CLIENT,SERVER) || $waitedpid;
$waitedpid=0, close CLIENT){
next if $waitedpid;
print "Got a connection on $NAME\n";
spawn;
}
sub REAPER{
$waitedpid = wait;
$SIG{CHLD} = \&REAPER;
print "Cleaned up child $waitedpid with exit $?\n";
}
sub spawn{
my $pid;
if(!defined($pid = fork)){
print "Cannot fork: $!";
return;
}elsif($pid){
print "begat $pid\n";
return;
}
print CLIENT "Hi\n";
exit;
}
---client side---
#!/usr/bin/perl
use Socket;
my($remote,$line);
$remote = "/usr/ch/data/dreg-socket";
unless(-S $remote){
die "Socket not found.";
}
socket(SOCK,PF_UNIX,SOCK_STREAM,0) || die "Socket: $!";
connect(SOCK, sockaddr_un($remote)) || die "Connect: $!";
while($line = <SOCK>){
print $line;
}
exit;
--
Erik Nielsen, Cyberhighway Internet Services NOC
I think that's easier to read. Pardon me. Less difficult to read.
-- Larry Wall in <199710120226.TAA06867@wall.org>
------------------------------
Date: Thu, 14 Jan 1999 01:20:31 GMT
From: stephen farrell <sfarrell@farrell.org>
Subject: Re: Year 2038 problem
Message-Id: <874spusl9c.fsf@couatl.uchicago.edu>
michal@gortel.phys.ualberta.ca (Michal Jaegermann) writes:
> Once again - applications are not limited to storing time in
> seconds in time_t format and quite often they do not. OTOH
> Unix file systems maintain file time stamps in such way.
And they do it with 32 bit integers, unfortunately. This is a
problem.
--sf
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4646
**************************************