[11373] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4973 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 26 11:37:25 1999

Date: Fri, 26 Feb 99 08:27:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Feb 1999     Volume: 8 Number: 4973

Today's topics:
    Re: flock() question <tchrist@mox.perl.com>
    Re: flock() question (Tad McClellan)
    Re: flock() question (Andrew M. Langmead)
    Re: flock() question <gsx97@usa.net>
    Re: flock() question <tchrist@mox.perl.com>
    Re: flock() question <jjpark@home.com>
    Re: FMTEYEWTK: Switch Statements (Ronald J Kimball)
    Re: foreach and while (Randal L. Schwartz)
    Re: foreach and while (Abigail)
    Re: foreach and while <rgoeggel@atos-group.com>
    Re: foreach and while <kenhirsch@myself.com>
    Re: foreach and while (Abigail)
    Re: foreach and while droby@copyright.com
        Forwarding mail <gzenker@pop500.gsfc.nasa.gov>
    Re: Forwarding mail (Clay Irving)
        Free Banner Exhange script info@gadnet.com
        Free online course for Perl 5 & CGI Programming <daveh@free-ed.net>
    Re: Free online course for Perl 5 & CGI Programming (Jonathan Stowe)
    Re: Free online course for Perl 5 & CGI Programming <jglascoe@giss.nasa.gov>
    Re: Free online course for Perl 5 & CGI Programming <Colin_Smith@euro.css.mot.com>
        Garbage collection error? <burton.not.spam@lucent.com>
    Re: Garbage collection error? (M.J.T. Guy)
        Get a return value from C program <donny@impulsesoftware.com>
    Re: Get a return value from C program (Clinton Pierce)
    Re: Get a return value from C program (Greg Bacon)
    Re: Get a return value from C program <jglascoe@giss.nasa.gov>
        GET IP address! (Sutha Balasubramaniam)
    Re: GET IP address! (Nobody)
        get process size m_i_c_h_a_e_l@my-dejanews.com
    Re: get process size <geoff@gdreyer.com>
    Re: get process size <stampes@xilinx.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 22 Feb 1999 05:09:31 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: flock() question
Message-Id: <36d148fb@csnews>

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

In comp.lang.perl.misc, justin <jjpark@home.com> writes:
:open(FH, ">$filename") || die "Cannot open $filename for write: $!";
:flock(FH, 2);

That's terribly wrong.  What good is shutting the barn door once the
horses have run away?  I've explained this many times in the last week.
Please use your newsreader or Deja News to find the appropriate postings.

--tom
-- 
"The reason you subscribe to a mailing list is you don't get all 
 the crap you get on netnews. "
	    --Dennis Ritchie


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

Date: Mon, 22 Feb 1999 02:39:58 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: flock() question
Message-Id: <ek1ra7.km1.ln@magna.metronet.com>

justin (jjpark@home.com) wrote:
: in the code:
: open(FH, ">$filename") || die "Cannot open $filename for write: $!";
: flock(FH, 2);
: print FH "--contents--";
: flock(FH, 8);
: close(FH);

: what happens? 


   My guess is "the file gets corrupted", since you have
   a race condition there.

   Do I win?  :-)


   (don't unlock, just close)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 22 Feb 1999 16:49:22 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: flock() question
Message-Id: <F7KEqA.8K8@world.std.com>

justin <jjpark@home.com> writes:

What happens? Lets give some running commentary:

>in the code:
>open(FH, ">$filename") || die "Cannot open $filename for write: $!";

This line opens and erases all of the contents of the file pointed to
by the name "$filename". The file is not locked at this point, so any
other process that tries to read the file at this point will get an
empty file.

>flock(FH, 2);

The empty file is now locked against other access from other processes
that ask for a lock. If any other processes attempt to lock, they the
kernel will stop all execution of the process until the lock is
removed.

>print FH "--contents--";

The string "--contents--" is put into the processes I/O buffers for
later writing to the file.

>flock(FH, 8);

The lock is now removed from the (possibly still empty) file. If there
are any processes waiting on the lock, the oldest one will be start
execution again an probably read the empty file. (Since this is such a
common mistake, later versions of perl perform an implicit flush of
the I/O buffers before unlocking. Do you know for sure that the
version of perl you are using is recent enough to workaround this bug
in your script?)

>close(FH);

Any data left in the I/O buffer is flushed and written to disk,
(changing the data from what was read by any process that now has the
lock.) and the file is closed.

>what happens? waits or return flock failed when other computer runs the same
>script at the same time and tries to flock at same time?

This is not the proper way to use the flock() calls. You don't even
the reading of the file in any part of your code. (The reading should
be done *after* the lock, not open/read/close/open/lock/write/close.
The entire sequence must be protected by locks.))

You really should take a look at the FAQ entry "I still don't get
locking.  I just want to increment the number in the file.  How can I
do this?" <URL:http://www.perl.com/CPAN-local/doc/manual/html/pod/
perlfaq5.html#I_still_don_t_get_locking_I_jus>
 
Lets take a look at it for comparison:

>use Fcntl;

Get the file control constants

>sysopen(FH, "numfile", O_RDWR|O_CREAT)    or die "can't open numfile: $!";

Open the file with read/write access, which will set the file pointer
to the beginning of the file and keep the contents undisturbed.

>flock(FH, 2)                              or die "can't flock numfile: $!";

Lock the file, to protect against access from other processes. Any
other process that tries to lock the file will be put to sleep.

>$num = <FH> || 0;

Read the first line in the file.

>seek(FH, 0, 0)                            or die "can't rewind numfile: $!";

Move the file pointer back to the beginning of the file (before the
line we just read.)

>truncate(FH, 0)                           or die "can't truncate numfile: $!";

reset the file's EOF to position 0. (make the file empty.)

>(print FH $num+1, "\n")                   or die "can't write numfile: $!";

Write the new contents into the file, carefully checking that the the
write actually succeeeded.

> # DO NOT UNLOCK THIS UNTIL YOU CLOSE
>close FH                                  or die "can't close numfile: $!";

Flush the I/O buffers, and then close the file, implicitly unlocking
any locks we have acquired. Now unlocked, any process that was put to
sleep because it requested a lock will be awoken and see the file's
contents as the data we have just written.

-- 
Andrew Langmead


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

Date: Mon, 22 Feb 1999 11:34:38 -0500
From: "J. Parsons" <gsx97@usa.net>
Subject: Re: flock() question
Message-Id: <7as0vh$nlm@news1.snet.net>

Tom,

In reference to the flock dilemma:   The CGI Programming FAQ at perl.com
shows the proper usage to be:

open (FILE, ">" . $counter) || die "Cannot write to counter file.\n";
flock (FILE, 2);
print FILE $visitors;
flock (FILE, 8);
close (FILE);

I had written scripts using flock under this premise, but have changed all
the code after reading the recent posts. I have read the FAQ's as well as 4
books I own on Perl. There seems to be many different approaches to flock
usage.

My one quick question: are the horses being let out between the open and the
flock, then the flock closes the door in the code above? This is the way I
interpret your message, but just want to see if my thought process is
correct. Like a wise man once said, practice is worthless if what you are
practicing is not correct!

Thanks for your input.

JP



Tom Christiansen wrote in message <36d148fb@csnews>...
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, justin <jjpark@home.com> writes:
>:open(FH, ">$filename") || die "Cannot open $filename for write: $!";
>:flock(FH, 2);
>
>That's terribly wrong.  What good is shutting the barn door once the
>horses have run away?  I've explained this many times in the last week.
>Please use your newsreader or Deja News to find the appropriate postings.
>
>--tom
>--
>"The reason you subscribe to a mailing list is you don't get all
> the crap you get on netnews. "
>     --Dennis Ritchie




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

Date: 22 Feb 1999 10:13:42 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: flock() question
Message-Id: <36d19046@csnews>

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

In comp.lang.perl.misc, 
    "J. Parsons" <gsx97@usa.net> writes:
:In reference to the flock dilemma:   The CGI Programming FAQ at perl.com
:shows the proper usage to be:

You mean www.perl.com, not perl.com.  They aren't the same.
And actually, it's on CPAN.  It hasn't been touched for years.
I'm removing it.

--tom
-- 
It is Unix.  It is possible to overcome any number of these bogus features. --pjw


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

Date: Mon, 22 Feb 1999 05:28:51 GMT
From: justin <jjpark@home.com>
Subject: Re: flock() question
Message-Id: <36D0EC15.9580451A@home.com>

in the code:
open(FH, ">$filename") || die "Cannot open $filename for write: $!";
flock(FH, 2);
print FH "--contents--";
flock(FH, 8);
close(FH);

what happens? waits or return flock failed when other computer runs the same
script at the same time and tries to flock at same time?


Juergen Heinzl wrote:

> In article <36CFEF90.C9340D81@home.com>, justin wrote:
> >what happens if you tries to flock a file that's already locked?
> >does it wait until the first lock is removed or does it return failure
> >flock?
>
> It depends on whether the LOCK_NB flag is set or not.
>
> Cheers,
> Juergen
>
> --
> \ Real name     : J|rgen Heinzl                 \       no flames      /
>  \ EMail Private : juergen@monocerus.demon.co.uk \ send money instead /
>   \ Phone Private : +44 181-332 0750              \                  /



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

Date: Sun, 21 Feb 1999 16:42:12 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: FMTEYEWTK: Switch Statements
Message-Id: <1dnl3jw.yay1ma1tvwxdcN@bay3-468.quincy.ziplink.net>

Michael, I would like to wish you the best of luck in obtaining a sense
of humor.  You have my sympathies.


Michael D. Schleif <mds-resource@mediaone.net> wrote:

> I'm sorry; but, did you read Tom's post, to which you responded?
> 
> Or, maybe you meant, why does Perl not have *only one* switch statement
> }:-P
> 
> Brad Baxter wrote:
> > 
> > Sure, but why doesn't Perl have a switch statement?  >:-)
> > 
> > On 19 Feb 1999, Tom Christiansen wrote:
> > > 
> > > So, anybody read this far? :-)


-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 23 Feb 1999 12:38:52 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: foreach and while
Message-Id: <m1k8x8onxf.fsf@halfdome.holdit.com>

>>>>> "Ronald" == Ronald Gvggel <rgoeggel@atos-group.com> writes:

Ronald> don't use 6 digit dates !

Why not?

I'm not going to start writing 1/2/2000 when 1/2/00 will work just
fine to indicate the second day of the first month of the closest year
ending in 00.

It's all about context.  4 digits doesn't magically fix everything.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 24 Feb 1999 00:46:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: foreach and while
Message-Id: <7avi5m$ao5$3@client2.news.psi.net>

Ronald Gvggel (rgoeggel@atos-group.com) wrote on MMII September MCMXCIII
in <URL:news:7auh6n$fl8$1@news.pop-stuttgart.de>:
!! 
!! don't use 6 digit dates !


Why not? There have been just over 730k dates since Jan 1, 1.
We still have about 738 years to go before a 6 digit counter rolls over.



Abigail
-- 
perl -wlpe '}{$_=$.' file  # Count the number of lines.


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

Date: Tue, 23 Feb 1999 16:06:11 +0100
From: "Ronald Gvggel" <rgoeggel@atos-group.com>
Subject: Re: foreach and while
Message-Id: <7auh6n$fl8$1@news.pop-stuttgart.de>

aaronp123@my-dejanews.com schrieb:
> 
> I have a pipe delimited data file like:
> $NAME|$EMAIL|$CREDIT|$DATE
> 
> That looks like:
> Jon128|jon@email.com|6|990108
> Jon128|jon@email.com|10|990308
> Bobh92|bob@doman.com|18|990308
> Jon128|jon@email.com|33|990508
> 

don't use 6 digit dates !


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

Date: Tue, 23 Feb 1999 22:11:54 -0500
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: foreach and while
Message-Id: <7avqm9$q9o$2@fir.prod.itd.earthlink.net>


Abigail wrote:
>Ronald Gvggel (rgoeggel@atos-group.com) wrote on MMII September MCMXCIII
>in <URL:news:7auh6n$fl8$1@news.pop-stuttgart.de>:
>!!
>!! don't use 6 digit dates !
>
>
>Why not? There have been just over 730k dates since Jan 1, 1.
>We still have about 738 years to go before a 6 digit counter rolls over.


That's a great point!  When I think of all those COBOL programmers "saving
storage" by omitting "19" but the representation allows only 36525 different
values out of 1,000,000 possible.  That's a storage efficiency of 3.65%.

But it's actually worse since the numbers were usually stored as packed
decimals (4 bytes giving .0008% efficiency) or unpacked decimal (6 bytes
giving .00000001% efficiency).


Ken Hirsch
Carrboro, NC







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

Date: 24 Feb 1999 05:04:41 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: foreach and while
Message-Id: <7b0199$diu$1@client2.news.psi.net>

Ken Hirsch (kenhirsch@myself.com) wrote on MMIII September MCMXCIII in
<URL:news:7avqm9$q9o$2@fir.prod.itd.earthlink.net>:
## 
## That's a great point!  When I think of all those COBOL programmers "saving
## storage" by omitting "19" but the representation allows only 36525 different
## values out of 1,000,000 possible.  That's a storage efficiency of 3.65%.


One should realize where the savings were done. It wasn't just for memory.
In those times, punchcards were much more common then they are now. With
just 80 characters on a punchcards. Putting a statement over 2 punchcards
was a much bigger deal then putting a newline in a Perl or C statement.

Note that this is a problem that occurs nowadays as well. Try formatting
a report that needs to print a transaction number, a counterparty, an
amount, a broker fee, transaction and maturity dates, and some other
stuff. And you only have 80 characters to play with, because putting
it over 2 lines is unacceptable.

It isn't fair to just blame COBOL for omitting the "19". Many applications
that suffer from some kind of y2k problem aren't written in COBOL. But
in C, or in some other language that depends on libc. With a tm struct
that stores years - 1900.

y2k problems happened as far back as 1970, when a financial program that
dealt with 30 year bonds went haywire on the first days of 1970. Yet, it
was still decided that tm was a good idea.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Thu, 25 Feb 1999 13:21:18 GMT
From: droby@copyright.com
Subject: Re: foreach and while
Message-Id: <7b3io6$o7q$1@nnrp1.dejanews.com>

In article <m1k8x8onxf.fsf@halfdome.holdit.com>,
  merlyn@stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "Ronald" == Ronald Gvggel <rgoeggel@atos-group.com> writes:
>
> Ronald> don't use 6 digit dates !
>
> Why not?
>
> I'm not going to start writing 1/2/2000 when 1/2/00 will work just
> fine to indicate the second day of the first month of the closest year
> ending in 00.
>
> It's all about context.  4 digits doesn't magically fix everything.
>

Use 5-digit years.  Be ready for Y10K well in advance.  ;-)

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 25 Feb 1999 10:42:54 -0500
From: Glenn Zenker <gzenker@pop500.gsfc.nasa.gov>
Subject: Forwarding mail
Message-Id: <36D56F7E.D3D4EEFC@pop500.gsfc.nasa.gov>

I need to forward mail to people with several messages in their inbox,
but I don't want to go in by hand and forward 500 messages to someone,
that would take all day.  Is there a script that can do this for me??

Any help would be appreciated.

Thanks...

- - - - - - - - - - - - - -
Glenn Zenker
gzenker@pop500.gsfc.nasa.gov





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

Date: 25 Feb 1999 11:19:00 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Forwarding mail
Message-Id: <slrn7datvi.f34.clay@panix.com>

On Thu, 25 Feb 1999 10:42:54 -0500, Glenn Zenker <gzenker@pop500.gsfc.nasa.gov> 
wrote:

>I need to forward mail to people with several messages in their inbox,
>but I don't want to go in by hand and forward 500 messages to someone,
>that would take all day.  Is there a script that can do this for me??
>
>Any help would be appreciated.

A program to do this should be east to write if you use the Mail::Tools
module:

   Mail:Tools
   http://www.perl.com/CPAN/modules/by-module/Mail

-- 
Clay Irving <clay@panix.com>
Jesus is coming, look busy



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

Date: Tue, 23 Feb 1999 15:48:42 GMT
From: info@gadnet.com
Subject: Free Banner Exhange script
Message-Id: <36d2cda9.23641164@news.newsguy.com>

If anyone wants a free banner / link exchange script, come to
http://www.gadnet.com/bplus/


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

Date: Wed, 24 Feb 1999 10:21:51 -0500
From: "David L. Heiserman" <daveh@free-ed.net>
Subject: Free online course for Perl 5 & CGI Programming
Message-Id: <ATUA2.1142$f2.1466@news2>

I have just launched a new, quality course for people who want a structured
path for learning practical programming for Perl 5 and CGI.  It's a great
place for experienced perl programmers to brush up on some details, and a
good place to send people who ask "Where can I get good perl/CGI training
for free?"

Take at look at our course -- free, no cost ... not ever:

http://www.free-ed.net/fr03/lfc/course%20030207_01/index.html

Thanks,

Dave Heiserman, Webmaster
www.free-ed.net





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

Date: Wed, 24 Feb 1999 17:11:41 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Free online course for Perl 5 & CGI Programming
Message-Id: <36d4322d.29698421@news.dircon.co.uk>

On Wed, 24 Feb 1999 10:21:51 -0500, "David L. Heiserman"
<daveh@free-ed.net> wrote:

>I have just launched a new, quality course for people who want a structured
>path for learning practical programming for Perl 5 and CGI.  It's a great
>place for experienced perl programmers to brush up on some details, and a
>good place to send people who ask "Where can I get good perl/CGI training
>for free?"
>
>Take at look at our course -- free, no cost ... not ever:
>
>http://www.free-ed.net/fr03/lfc/course%20030207_01/index.html
>

<quote my emphasis>

About the Course

This is a complete course in Perl 5 programming <EM>(more properly
called scripting)</EM> with CGI applications. The required equipment
and materials are:
</quote>

Oh lets not start that again......

/J\


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

Date: Wed, 24 Feb 1999 13:33:37 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
Subject: Re: Free online course for Perl 5 & CGI Programming
Message-Id: <36D44601.10AAD8E3@giss.nasa.gov>

Jonathan Stowe quotes http://www.free-ed.net/fr03/lfc/course%20030207_01/index.html:
> 

<snip>

> This is a complete course in Perl 5 programming <EM>(more properly
> called scripting)</EM> with CGI applications. The required equipment
> and materials are:

<snip>

and then writes:
> 
> Oh lets not start that again......
> 
> /J\

perl -ne 's/scripting/hacking ;-\)/i; print' < index.html > index.new.html

	Jay
-- 
mongering?


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

Date: Thu, 25 Feb 1999 12:26:31 +0000
From: Colin Smith <Colin_Smith@euro.css.mot.com>
Subject: Re: Free online course for Perl 5 & CGI Programming
Message-Id: <36D54177.B99A574A@euro.css.mot.com>

Great I thought. Might be worth taking a look at I thought, until..........

"
This is a complete course in Perl 5 programming (more properly called
scripting) with CGI applications. The required equipment and materials
                                                         are:

                                                            1.A
Windows-compatable PC
                                                            2.Windows 95 or 98
installed
                                                            3.Microsoft Notepad
or similar text editor
                                                            4.Access to a Perl
compiler that is running under one of the major
                                                              operating systems
such as Unix, Windows95/NT, or OS/2.
                                                              Note: Lesson 1
describes how you can  find, obtain,  install, or do whatever is
                                                              necessary to
access a Perl compiler.
"

"David L. Heiserman" wrote:

> I have just launched a new, quality course for people who want a structured
> path for learning practical programming for Perl 5 and CGI.  It's a great
> place for experienced perl programmers to brush up on some details, and a
> good place to send people who ask "Where can I get good perl/CGI training
> for free?"
>
> Take at look at our course -- free, no cost ... not ever:
>
> http://www.free-ed.net/fr03/lfc/course%20030207_01/index.html
>
> Thanks,
>
> Dave Heiserman, Webmaster
> www.free-ed.net

--
Colin Smith
Cellular Subscriber Sector Europe
Colin_Smith@euro.css.mot.com
Phone: +44 (0)1256 790 261




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

Date: Tue, 23 Feb 1999 11:00:23 -0600
From: Burton Kent <burton.not.spam@lucent.com>
Subject: Garbage collection error?
Message-Id: <36D2DEA7.F3E86DCA@lucent.com>

My program does some recursive work, which might be
causing the following message when exiting:

Attempt to free unreferenced scalar, <STDIN> chunk 9.

What do I look for to fix this?  Am I right in thinking
this is garbage collection?

Burton


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

Date: 24 Feb 1999 00:39:32 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Garbage collection error?
Message-Id: <7avho4$bk8$1@pegasus.csx.cam.ac.uk>

Burton Kent  <burton.not.spam@lucent.com> wrote:
>My program does some recursive work, which might be
>causing the following message when exiting:
>
>Attempt to free unreferenced scalar, <STDIN> chunk 9.
>
>What do I look for to fix this?  Am I right in thinking
>this is garbage collection?

Well, perldiag says about this error

     Attempt to free unreferenced scalar
         (W) Perl went to decrement the reference count of a
         scalar to see if it would go to 0, and discovered that
         it had already gone to 0 earlier, and should have been
         freed, and in fact, probably was freed.  This could
         indicate that SvREFCNT_dec() was called too many times,
         or that SvREFCNT_inc() was called too few times, or that
         the SV was mortalized when it shouldn't have been, or
         that memory has been corrupted.

so, yes, it is "garbage collection", as Perl understands it.

And despite the (W) designation, this is a "should not happen" error,
so is a bug in Perl.   Though such bugs are often provoked by bad
recovery from a user error.

How to fix it?    No easy answer.   If you aren't already running the
latest and greatest Perl version, please try that.   Many bugs of this
sort have been mended since older releases.

And if that doesn't help, you'll need to try cutting down your script
to a sufficiently short one which exhibits the error, then send the
result in a bug report.   (See the perlbug script.)


Mike Guy


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

Date: Thu, 25 Feb 1999 20:32:02 GMT
From: Donny Widjaja <donny@impulsesoftware.com>
Subject: Get a return value from C program
Message-Id: <36D5B35D.8336F622@impulsesoftware.com>

Hi,

How do I call a compiled C/C++ program from Perl?  How can I get the
return value from the C/C++ program?

Thank you.


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

Date: Thu, 25 Feb 1999 20:50:28 GMT
From: clintp@geeksalad.org (Clinton Pierce)
Subject: Re: Get a return value from C program
Message-Id: <36d9b733.881206849@news.ford.com>

On Thu, 25 Feb 1999 20:32:02 GMT, Donny Widjaja
<donny@impulsesoftware.com> wrote:

>Hi,
>
>How do I call a compiled C/C++ program from Perl?  How can I get the
>return value from the C/C++ program?
>
>Thank you.

run:

perldoc perlfunc

And check out the entries for ....system(), open(), and also
fork()/exec()/wait().


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

Date: 25 Feb 1999 21:40:16 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Get a return value from C program
Message-Id: <7b4g00$fb9$4@info.uah.edu>

In article <36D5B35D.8336F622@impulsesoftware.com>,
	Donny Widjaja <donny@impulsesoftware.com> writes:
: How do I call a compiled C/C++ program from Perl?  How can I get the
: return value from the C/C++ program?

Read the perlfunc entry on system().

Greg
-- 
Fenster: Treat me like a criminal, I'll end up a criminal.
Hockney: You are a criminal.
Fenster: Why you gotta go and do that? I'm trying to make a point.


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

Date: Thu, 25 Feb 1999 16:48:35 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Donny Widjaja <donny@impulsesoftware.com>
Subject: Re: Get a return value from C program
Message-Id: <36D5C533.FD6E60AB@giss.nasa.gov>

[courtesy copy sent to Donny via email]

Donny Widjaja wrote:
> 
> Hi,
> 
> How do I call a compiled C/C++ program from Perl?  How can I get the
> return value from the C/C++ program?

my $retval = system("/bin/echo 'foo'");	# "retval" is now 0

or perhaps

system("/bin/echo 'foo'") == 0 or die "ugh: $!";

OTOH, you can do
	
my $output = `/bin/echo "foo"`;  	# "output" is now "foo\n"


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

Date: 24 Feb 1999 20:47:44 GMT
From: sbalasu3@chat.carleton.ca (Sutha Balasubramaniam)
Subject: GET IP address!
Message-Id: <7b1ohg$427$1@bertrand.ccs.carleton.ca>


Hi,	
	Can someone tell me how can I get the infos like IP address of a
user from  a perl script? I would appreciate your helps.

thx
Sutha.B


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

Date: 25 Feb 1999 01:16:40 GMT
From: nobody@dewpoint.eng.sun.com (Nobody)
Subject: Re: GET IP address!
Message-Id: <7b289o$rqa$1@engnews2.Eng.Sun.COM>

In article <7b1ohg$427$1@bertrand.ccs.carleton.ca> sbalasu3@chat.carleton.ca (Sutha Balasubramaniam) writes:
>
>Hi,	
>	Can someone tell me how can I get the infos like IP address of a
>user from  a perl script? I would appreciate your helps.
>
>thx
>Sutha.B

Do a system call for arp "hostname" and then search for the IP address from the
output?

EDEW


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

Date: Mon, 22 Feb 1999 19:35:47 GMT
From: m_i_c_h_a_e_l@my-dejanews.com
Subject: get process size
Message-Id: <7asbij$jgm$1@nnrp1.dejanews.com>

How do I efficiently find out how the size (i.e. amount of memory used)
of my perl process on a unix machine (e.g. solaris)?  (I need to do this
operation frequently within the program  to try to track down when my
program unexpectedly allocates a huge amount of memory unnecessarily)

Thanks in advance for any help!
Michael Niv.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 23 Feb 1999 10:26:27 -0800
From: Geoff Dreyer <geoff@gdreyer.com>
Subject: Re: get process size
Message-Id: <36D2F2D3.4D853EBA@gdreyer.com>

m_i_c_h_a_e_l@my-dejanews.com wrote:

> How do I efficiently find out how the size (i.e. amount of memory used)
> of my perl process on a unix machine (e.g. solaris)?  (I need to do this
> operation frequently within the program  to try to track down when my
> program unexpectedly allocates a huge amount of memory unnecessarily)
>
> Thanks in advance for any help!
> Michael Niv.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

  Have you had a look at BSD::Resource from CPAN?  You can do stuff like
print getrusage()->maxrss, "\n";
and other resource info.

Hope this helps
-Geoff



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

Date: 22 Feb 1999 20:15:56 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: get process size
Message-Id: <7asdts$7o1@courier.xilinx.com>

m_i_c_h_a_e_l@my-dejanews.com wrote:
: How do I efficiently find out how the size (i.e. amount of memory used)
: of my perl process on a unix machine (e.g. solaris)?  (I need to do this
: operation frequently within the program  to try to track down when my
: program unexpectedly allocates a huge amount of memory unnecessarily)

Think outside the perl 'box'....

When I've needed to do this, I've simply pulled up one xterm running 
top, set to update every second, and in another shell I step through
the script in the debugger.

There's bound to be a perl solution also, but this is the 
quick'n'easy way to get to your destination until someone helps
with that.

Cheers,

jeff

-- 
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

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

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