[7232] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 857 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 13 04:17:22 1997

Date: Wed, 13 Aug 97 01:00:43 -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           Wed, 13 Aug 1997     Volume: 8 Number: 857

Today's topics:
     %ENV doesn't work with PerlIS on NT S <pegit.swedmap@mbox300.swipnet.se>
     ??  perl5  ?? problem installing (Andrew Galdes)
     about -e and getting filenames <kin@wco.com>
     Re: about -e and getting filenames <rootbeer@teleport.com>
     Re: Buffering output: NT vs Linux differences with the  <sanford@halcyon.com>
     Bug in sort at 5.003? train12@cacd.rockwell.com
     Can You Title Case A String ?. <andy@pindar.com>
     Re: complex argument passing <rootbeer@teleport.com>
     converting from hex <mystery@itis.com>
     create a file in a user directory with a perl script .. <srichard@san-jose.ate.slb.com>
     create a file in a user directory with a perl script .. <srichard@san-jose.ate.slb.com>
     Re: emacs?  No thank you <rootbeer@teleport.com>
     Re: Enabling MS Personal Web Server to run Perl. <rootbeer@teleport.com>
     Re: Frustration and -T <rootbeer@teleport.com>
     Re: Help, Help, Help... This is killing me... <cs@zip.com.au>
     Re: How to open a file to a variable instead of an arra <rootbeer@teleport.com>
     Re: Large Data Base question <rootbeer@teleport.com>
     Re: map problem <rootbeer@teleport.com>
     Math Problem in foreach loop (Ranson)
     Re: Math Problem in foreach loop <rootbeer@teleport.com>
     Passing dos errorlevel into Perl script <chengc@ichips.intel.com>
     Re: Perl and ODBMS (Danny Aldham)
     Perl DDE? Mentors? <cc1179%SPAM%@cocentral.com>
     PerlShop <erbeck@web-design.net>
     Re: Problem with ENV{REMOTE_USER} <qdtcall@esb.ericsson.se>
     Problems with split crr026@email.mot.com
     Script testing <yngwie@erols.com>
     Re: SelfLoader and -T <rootbeer@teleport.com>
     Re: Sorting Challenge (Greg Bacon)
     Re: Stuck on math problem (Tad McClellan)
     Time problem. (Charles Boone)
     Re: Time problem. <rootbeer@teleport.com>
     typeglob in perl 4 and 5 (Terry von Gease)
     Re: typeglob in perl 4 and 5 <rootbeer@teleport.com>
     Re: Using perl noninternet, stand alone for processing! <rootbeer@teleport.com>
     Re: Using perl noninternet, stand alone for processing! (Tad McClellan)
     Using scripts and such off of browser off line??? <rudedog@pld.com>
     Re: What is the littlest Perl? <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Aug 1997 08:44:59 +0200
From: Pinne <pegit.swedmap@mbox300.swipnet.se>
Subject: %ENV doesn't work with PerlIS on NT S
Message-Id: <33F157EA.6FCE@mbox300.swipnet.se>

Hi,

Sorry if you see this posting more than once,
but as usually I can4t see it at all.
I'm running PerlIS (Perl 5.003 bld 306) on NT
S 4.0 with IIS 3.0.
Before installing IIS 3.0 Perl.exe worked fine.
But when I tried to reinstall (had a crash) Perl
on NT, the exe-version wouldn't work.
Don't exactly remember what the error messages were.
However, PerlIS did work fine and since that's a dll
it should be much better, at least I would get rid
of some overhead. 
But there's one big problem, there's no info in the
%ENV-array.
Can anyone tell me if that is so, or did I miss something.
Are there any more drawbacks to using the dll instead of
the exe ?
Please, please, please any help on this matter would
be most appriciated.
If, Please reply by email.
/regards


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

Date: Wed, 13 Aug 1997 04:24:05 GMT
From: galdes.andrew@pi.sa.gov.au (Andrew Galdes)
Subject: ??  perl5  ?? problem installing
Message-Id: <5srgac$t9j@internal.sa.gov.au>

G'day,
I am another one of those people having trouble with perl5. i am got a
version for DOS (16bit) but it didn't work at all. i would like to
know if there are any woking versions of PERL5 out there (preferably
for 16bit PC. WIN95 would also be nice. Couls anyone send me a ZIP of
perl which might be what i want? Thanks for your time.
Andrew



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

Date: Tue, 12 Aug 1997 22:57:18 -0700
From: Kenneth Kin Lum <kin@wco.com>
Subject: about -e and getting filenames
Message-Id: <33F14CBE.300CC755@wco.com>

Is there a way to do
  if (-e "*.txt") { ... }
?  That is, must "-e" take an exact filename but can't take
a wildcard?

Also, is there a way not to fork a process but just do in PERL to do
  foreach $file (`ls *.txt`) { ... }

This is because forking a process on my ISP's server is
really slow.

Could you please also CC to me when respond.  Thanks.


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

Date: Tue, 12 Aug 1997 23:46:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Kenneth Kin Lum <kin@wco.com>
Subject: Re: about -e and getting filenames
Message-Id: <Pine.GSO.3.96.970812234328.29850d-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Kenneth Kin Lum wrote:

> Is there a way to do
>   if (-e "*.txt") { ... }
> ?  That is, must "-e" take an exact filename but can't take
> a wildcard?

Maybe you're looking for globbing, documented in the perlfunc(1) manpage. 

    @txt_files = glob('*.txt');

> Also, is there a way not to fork a process but just do in PERL to do
>   foreach $file (`ls *.txt`) { ... }

Do you mean that you want to get the information which ls prints about a
file? If so, you probably want the stat function, and possibly lstat as
well.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 12 Aug 1997 16:41:54 -0700
From: Sanford Morton <sanford@halcyon.com>
To: jadigby@magna.com.au
Subject: Re: Buffering output: NT vs Linux differences with the $| variable ?
Message-Id: <m3vi1b55q5.fsf@halcyon.com>

Followups set to comp.infosystems.www.authoring.cgi

Server push requires nonparsed headers, which means your script is
responsible for returning HTTP headers, something the server routinely
does for most scripts.  

Telnet to port 80 of a web server and type

GET / HTTP/1.0

followed by two carriage returns to see some HTTP headers.

Your script bufferred ok, but failed to return required HTTP
headers. If it worked on NT as you claim, then I can only surmise your
NT web server is broken. Try the following script instead:

  #!/usr/bin/perl
  
  $| = 1;
  print "HTTP/1.0 200\n";
  print "Content-type: multipart/x-mixed-replace; boundary=ThisRandomString\n\n";
  
  print "--ThisRandomString\n";
  $i = 0;
  while ($i < 10) {
      $i++;
      print "Content-type: text/html\n\n";
      print "<html><body><title>This is run $i</title>\n";
      print "<h1>This is run $i</h1></body></html>\n";
      print "--ThisRandomString\n";
      sleep 2;
  }
  
  exit 0;              

--------
Sanford Morton, Ph.D.                           CGI Resources
sanford@halcyon.com       http://www.halcyon.com/sanford/cgi/


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

Date: Tue, 12 Aug 1997 10:19:27 -0500
From: train12@cacd.rockwell.com
Subject: Bug in sort at 5.003?
Message-Id: <33F07EFF.78E9@cacd.rockwell.com>

Seems to be a problem with sort on my version, anyone
else seen something similar on other ports?

Here is the questionable code:
   #!/usr/remote/bin/perl
   @x = sort (50,10,2,30,4);
   print "@x\n"; #results in the incorrect 10 50 2 4 30
   #but!!!:
   @x = sort { $a cmp $b } (50,10,2,30,4);
   print "@x\n"; #results in the correct 10 2 30 4 50
   @x=(50,10,2,30,4);
   @x=sort(@x);
   print "@x\n"; #Also results in the correct 10 2 30 4 50

This was run on 5.003, but I have never noticed this on other ports,
then, I don;t usually sort literal lists, just happened across this.

Here is the perl -v info:

   This is perl, version 5.003 with EMBED
        built under hpux at Nov  7 1996 15:15:30
        + suidperl security patch


Thanks for any info
Fred Mallett
frederm@famece.com


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

Date: Tue, 12 Aug 1997 16:05:15 +0100
From: Andy Marr <andy@pindar.com>
Subject: Can You Title Case A String ?.
Message-Id: <33F07BA6.46A2@pindar.com>

Just a quick one.

I have a string "THIS IS A STRING" and I want to 
format it to "This Is A String". (Cap at the start of each word).

Is there a command in Perl to do this ? , or do I have to split the
string again and change to lower case and upper case the first letter ?
 .

I know the following would work for each word in the string.

@word = split ( / / ,$string);
print ("\L\u@word[x]\E\n");

It just seems the long way round , any suggestions ?.

Thanks 
Andy Marr.


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

Date: Tue, 12 Aug 1997 22:47:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Dean Hoover <dhoover@textwise.com>
Subject: Re: complex argument passing
Message-Id: <Pine.GSO.3.96.970812224606.29850S-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Dean Hoover wrote:

> die "can SETVAL[0]\n" unless defined semctl($id, 0, &SETVAL, pack("i",
> $initval));
> 
> this is the way it reads in C (Stevens):
> 
> semctl_arg.val = initval;
> if (semctl(id, 0, SETVAL, semctl_arg) < 0)
> 	err_sys("can SETVAL[0]");
> 
> what is the difference?

I'm not sure. Do you know exactly what bytes are passed by C? If so, we
can either get Perl to pass exactly those same bytes, or we can file a bug
report. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 11 Aug 1997 13:26:39 -0400
From: Prince Mystery <mystery@itis.com>
Subject: converting from hex
Message-Id: <33EF4B4F.AC59135E@itis.com>

Hi,

I'm trying to take a hex rgb value (ala #ffffff) and convert it to a
three member array of decimal equivalents for each of those values, r,
g, and b.

for example:

string '#ffffff' would then produce (255,255,255);

Thanks for your help,

Myst
-- 

Version: 2.6.2

owEBiAB3/4kAdQMFADPY9d1hGXgCUdEssQEBvREDAJodjyXMMZnOxrzl6Z5Anldh
p/mCNLshfYr/aLB+vmR2CrdySGCqBZFg+GanInyn/Vg6oRNoLgM/sU5+sbYntGt1
nI2B8/PZIDxOTA3S6BktLawONN/RGcqjPhDPm8l636wOYgh0ZXh0ZmlsZQAAAAA=
=beaq
-----END PGP MESSAGE-----


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

Date: Tue, 12 Aug 1997 19:07:45 -0400
From: Stephane RICHARD <srichard@san-jose.ate.slb.com>
Subject: create a file in a user directory with a perl script ...
Message-Id: <33F0ECC1.AE4C5780@san-jose.ate.slb.com>


--------------2E0E967AC6B281AF581D41BD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello,

I need some help :

        I'm looking for the best way for an user to create by the web a
file in his own directory on an Unix system.
 ...  A Perl script get the information from a web page and create a
 .forward file in the directory of the user.

I've think about this : the perl script call another perl script with
the root level and this last script create the file in the directory of
an Unix user ...

Others Ideas ?

Stef.

--------------2E0E967AC6B281AF581D41BD
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Hello,

<P>I need some help :
<BR>&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I'm looking for the best
way for an user to create by the web a file in his own directory on an
Unix system.
<BR>...&nbsp; A Perl script get the information from a web page and create
a&nbsp; <I>.forward</I> file in the directory of the user.

<P>I've think about this : the perl script call another perl script with
the root level and this last script create the file in the directory of
an Unix user ...

<P>Others Ideas ?

<P>Stef.</HTML>

--------------2E0E967AC6B281AF581D41BD--



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

Date: Tue, 12 Aug 1997 19:07:31 -0400
From: Stephane RICHARD <srichard@san-jose.ate.slb.com>
Subject: create a file in a user directory with a perl script ...
Message-Id: <33F0ECB3.DDA4D84A@san-jose.ate.slb.com>


--------------58B4A11F79CFD23FA227C5DE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello,

I need some help :

        I'm looking for the best way for an user to create by the web a
file in his own directory on an Unix system.
 ...  A Perl script get the information from a web page and create a
 .forward file in the directory of the user.

I've think about this : the perl script call another perl script with
the root level and this last script create the file in the directory of
an Unix user ...

Others Ideas ?

Stef.

--------------58B4A11F79CFD23FA227C5DE
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Hello,

<P>I need some help :
<BR>&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I'm looking for the best
way for an user to create by the web a file in his own directory on an
Unix system.
<BR>...&nbsp; A Perl script get the information from a web page and create
a&nbsp; <I>.forward</I> file in the directory of the user.

<P>I've think about this : the perl script call another perl script with
the root level and this last script create the file in the directory of
an Unix user ...

<P>Others Ideas ?

<P>Stef.</HTML>

--------------58B4A11F79CFD23FA227C5DE--



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

Date: Tue, 12 Aug 1997 22:38:32 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Kenneth Vogt <KenVogt@rkymtnhi.com>
Subject: Re: emacs?  No thank you
Message-Id: <Pine.GSO.3.96.970812223743.29850N-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Kenneth Vogt wrote:

> What I need is a way to DEBUG perl under Windows 95.

Have you seen the perldebug(1) manpage? Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 Aug 1997 22:44:28 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: box16@usa.net
Subject: Re: Enabling MS Personal Web Server to run Perl.
Message-Id: <Pine.GSO.3.96.970812224154.29850R-100000@julie.teleport.com>

On Tue, 12 Aug 1997 box16@usa.net wrote:

> Does anybody know if the MS Personal Web Server can run Perl scripts, 
> and if so how does one enable the server to do so?

This may be surprising, but your question is actually about a server
rather than about Perl. A server newsgroup would be better-equipped to
answer your questions about your server, and will likely be able to give
you quicker, more complete, and more accurate answers than you could get
here. Of course, if you have questions about Perl which aren't answered in
the docs and FAQs, you're welcome to post those questions here. And I hope
you'll get everything working soon; good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 Aug 1997 22:20:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: tina@mail.scandinaviaonline.se
Subject: Re: Frustration and -T
Message-Id: <Pine.GSO.3.96.970812221253.29850L-100000@julie.teleport.com>

On 12 Aug 1997, Tina Marie Holmboe wrote:

>     $PerlCode =<<EoD;
> sub {
>   print 1 ;
> }
> EoD
>     $Code = eval($PerlCode) ;               # Did *not* work...         (3)

>   All in all it was a rather frustrating situation. What bothered me the
> most was the utter lack of error messages. Finally it dawned on me that
> *perhaps* this was due to the -T, and Perl seeing that last eval() as
> tainted. It did... 

Are you saying that $PerlCode in the above example was tainted? I can't
duplicate this in my tests. If you can, could you file a bug report?

Are you saying that eval on a tainted string doesn't give any error
message upon dying? I can't duplicate that either. If you can, you know
what to do. :-) 

Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1997 01:38:47 GMT
From: Cameron Simpson <cs@zip.com.au>
To: "Stephon" <webmaster@sony.com>
Subject: Re: Help, Help, Help... This is killing me...
Message-Id: <19970813120212-cameron-1-13500@sid.research.canon.com.au>

"Stephon" <webmaster@sony.com> writes:
| I'm stumped...  Can anyone figure way the hell this piece of script is not
| working???  And I am pretty sure the answer is simple.  Here are the
| details:
[...]

Perhaps it's aborting early. Error messages will be in the log file
(what a pain). Behold my _favourite_ piece of CGI debugging code,
prepended to every script:

BEGIN	{ open(STDERR,"|/usr/local/script/mailif -s test-ts2.cgi-err cameron");
	}

mailif is a script which emails the named user with the specified
subject line _if the email is not empty_. That way you get nicerly
packaged error reports and silence when things work.
	- Cameron Simpson, cs@zip.com.au, DoD#743
	  http://www.zip.com.au/~cs/
--
The first rule of Italian driving: What is behind me is _not_ important!
	- The Gumball Rally, on the removal of the rearview mirror


#!/bin/sh
#
# Send mail only if input is not empty.
#	- Cameron Simpson <cs@zip.com.au>
#
# Usage: mailif [-s subject] addresses...
#

subject=
case "$#,$1" in
	0,*|1,*)	;;
	*,-s)		subject="Subject: $2"; shift; shift ;;
esac

[ $# = 0 ] && { echo "Usage: $0 [-s subject] addresses..." >&2; exit 2; }

them=$1; shift
while :
do
    case $# in 0) break ;; esac
    them="$them, $1"
    shift
done

trap 'rm -f "$tmp"; exit 1' 1 15

tmp=/tmp/mailif.$$
sed -n -e '/^[ 	]*$/d
	   :again
	   p
	   n
	   b again' >"$tmp"

if [ -s "$tmp" ]
then
    ( echo "To: $them"
      [ -n "$subject" ] && echo "$subject"
      echo
      cat "$tmp"
    ) | /usr/lib/sendmail -oi -t
    xit=$?
else
    xit=0
fi

rm "$tmp"

exit $xit


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

Date: Tue, 12 Aug 1997 23:42:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Morten Simonsen <mortensi@idt.ntnu.no>
Subject: Re: How to open a file to a variable instead of an array?
Message-Id: <Pine.GSO.3.96.970812233048.29850c-100000@julie.teleport.com>

On 12 Aug 1997, Morten Simonsen wrote:

> : > How can i open a file to a variable instead of an array?
> 
> : What do you mean by "open a file to a variable"? Do you want to put
> : the contents of a file into a single variable? Do you want to open a
> : file whose name is conatined in a variable?
> : Have you read any of the Learning Perl documentation?
> 
> I think the previous post is a good example of what sould NOT
> be posted. It has no information except: "read the docs". 

That's not true; it also offers some questions. The answers to those
questions may help all of us to help the original poster to find out what
he or she wants and how to make it happen. Even thinking about those
questions may set the poster on the path to a solution. Don't you agree
that the Socratic method can be useful? :-) 

> It even shows that he has trouble understanding what the question is,

Indeed. It's not a clear question. Among other things, it presupposes that
an 'array' is not a 'variable', so it makes me wonder what other words
have different meanings than I'm used to. 

> I would say it's only to make trouble.

I would say that you would be wrong. :-)  (What motive would someone have
to wish "only to make trouble"? Wouldn't they be able to make more trouble
more easily than by taking the trouble to write out an answer to a
question in a newsgroup?)

> Here is my solution to the question (which I did understand), 

Are you _sure_ that you have the same idea as the original poster? I'm not
saying that you don't. But it is possible that you have a different idea;
I can think of at least one other plausible interpretation of the
question. 

> but I don't know wether it's especially efficient, it's just a solution:
> 
>   open(FILE,$filename);
>   read(FILE,$filevar,stat(FILE)[7]);
> 
> Now the $filevar contains the whole FILE.

Maybe it does, but it's likely that it doesn't. The open may have failed,
the read may have been interrupted, other problems may have happened. 

I hope that this won't be seen by you as only an attempt to make trouble; 
I'm sincerely trying to be helpful! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 Aug 1997 22:50:19 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Stephen Hill <buck@huron.net>
Subject: Re: Large Data Base question
Message-Id: <Pine.GSO.3.96.970812224841.29850T-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Stephen Hill wrote:

> I am going to have a large database, about 1 gig. Would perl be
> appropriate to use to search this database or would some other language
> be more appropriate?

Since Perl uses compiled C routines to access a large database (just as a
C program would) I'd say Perl is appropriate for that task. :-)  Hope this
helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 Aug 1997 22:59:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Thomas Andrews <thomaso@shell3.ba.best.com>
Subject: Re: map problem
Message-Id: <Pine.GSO.3.96.970812225719.29850V-100000@julie.teleport.com>

On 13 Aug 1997, Thomas Andrews wrote:

> >  foreach (@b = @a) { s/bb$//; }

> Why use "foreach" :-)
> 
> 	grep ( s/bb$// , @b=@a );

I hope that the smiley indicates that you know that you're posting an
answer which is in no way better (and arguably worse) than the one you
quoted. But in case somebody who doesn't know better reads your message, I
hope that they also read mine, so that they will know better. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1997 02:02:19 GMT
From: ranson@infoave.net (Ranson)
Subject: Math Problem in foreach loop
Message-Id: <5sr4jb$jas@news1.infoave.net>


Greetings, I am trying to figure a simple? math equation within a 
foreach loop.
I know it has to be simple but just can not get the sytax correct.
I just need to add any number of items stored in a temp file and
 produce a 
total. $total

In the code below i need to add each $subtotal and produce a $total

The best I have been able to get is: 12 30 42 60 72 90 - 90 IS the
 correct total 
for all $subtotal - but can't get rid of the 12 30 42 60 72

Any help is appricated. And thanks for all of you who have helped me 
in the past.

Ranson


open (TEMP, "$path/cgi/tmp/$temp_file");
@tmplines = <TEMP>;
close (TEMP);
foreach $tmpline (@tmplines)

{

    ($Item_no, $item_desc, $Item_quan, $Item_cost, $Item_unit) = split(/:/,$tmpline);

    $tempItem_no{$Item_no}=$Item_no;
    $tmpItemDesc{$Item_no}=$item_desc;
    $tmpQuan{$Item_no}=$Item_quan;
    $tmpCost{$Item_no}=$Item_cost;
    $tmpUnit{$Item_no}=$Item_unit;

$subtotal = $tmpQuan{$Item_no} * $tmpCost{$Item_no};

$total += $subtotal;

        print "<TR><TD>$tmpItemDesc{$Item_no}</TD>";

        print "<TD ALIGN=left>&nbsp; &nbsp; &nbsp; $tmpQuan{$Item_no}</TD>";

        print "<TD ALIGN=left>&nbsp; &nbsp;$tmpCost{$Item_no}</TD>";

        print "<TD ALIGN=left>&nbsp; &nbsp;$tmpUnit{$Item_no}</TD>";

        print "<TD ALIGN=left>&nbsp; &nbsp;$subtotal</TD>";

        print "</TR>$total\n";

	
 } # End of foreach



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

Date: Tue, 12 Aug 1997 23:50:11 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ranson <ranson@infoave.net>
Subject: Re: Math Problem in foreach loop
Message-Id: <Pine.GSO.3.96.970812234805.29850e-100000@julie.teleport.com>

On 13 Aug 1997, Ranson wrote:

> The best I have been able to get is: 12 30 42 60 72 90 - 90 IS the
>  correct total 
> for all $subtotal - but can't get rid of the 12 30 42 60 72

I think you're saying that you get the right answer, but you don't want to
print the intermediate results. Why not move the statement which prints
the total out of the foreach loop? If it's in the loop, it prints once for
each item, but if you move it after the loop, it should print just once
for the whole list. 

> open (TEMP, "$path/cgi/tmp/$temp_file");

And always check the return value from open.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 Aug 1997 17:53:47 -0700
From: chengc <chengc@ichips.intel.com>
Subject: Passing dos errorlevel into Perl script
Message-Id: <33F1059B.73BB@ichips.intel.com>

Hi, I'm executing DOS batch file through perl system call. Wants to pass
the %errorlevel% var in the DOS batch into $? in PERL. Any ideas? Help
is appreciated.

Cheng Cheng
Intel Corp.


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

Date: 12 Aug 1997 20:45:46 -0700
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: Perl and ODBMS
Message-Id: <5srala$ico$1@lennon.postino.com>

Raz Shlomovich (raz_s@NetVision.net.il) wrote:
: Accessing ODBMS from Perl - any idea?
: Anyone consider writing Versant/ObjectStore/O2 extension ?

How about any of the Modules, DBD/DBI , Oracle, Pg, MsSQL, etc, etc.
availiable at any CPAN site? I have tried the Pg module, and the 
Win32 Module, both work great.

--
Danny Aldham           SCO Ace , MCSE , JAPH , DAD
I don't need to hide my e-mail address, I broke my sendmail.


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

Date: Wed, 13 Aug 1997 07:48:46 GMT
From: "Raymond M. Burke" <cc1179%SPAM%@cocentral.com>
Subject: Perl DDE? Mentors?
Message-Id: <01bca7ad$6684eee0$b7ec64ce@cc1179.cocentral.com>

I'm new to Perl and use it on a Win95 machine. I'm wondering if it's
possible to use DDE in Perl?

Also, if any experienced Perl programmers want to be a mentor to a Perl
newbie, contact me, please!

Raymond M. Burke
Remove %SPAM% from address to reply.



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

Date: Wed, 13 Aug 1997 01:07:18 -0500
From: Beck Web Virtual Servers & Design <erbeck@web-design.net>
Subject: PerlShop
Message-Id: <33F14106.682F@web-design.net>

Hi:

I'm usually pretty good at troubleshooting scripts, and getting them to
work on  my virtual server, but I can't get PerlShop going on my
server.  I've tried everything I can think of.  I'd really appreciate it
if I could shoot my script over to someone who's familiar with PerlShop,
and if they could tell me what the heck I'm doing wrong or why it won't
work.

It runs from the shell...no errors.
>From the web....as soon as I try to enter the store....I get a Server
Error, misconfiguration or internal error...argghhhh.  I've looked at it
upside down, and sideways....

Eric Beck  admin@remove-itweb-design.net  #remove you know what


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

Date: 13 Aug 1997 09:23:59 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Problem with ENV{REMOTE_USER}
Message-Id: <isd8ni35rk.fsf@godzilla.kiere.ericsson.se>

"Mai Yang [I]" <yangma@cig.mot.com> writes:

> I need to know the name of the person who is accessing my homepage. I
> examined the enviroment variable ENV{REMOTE_USER} and ENV{HTTP_FROM} to
> get the user's name and email. But both turned out to be null. I then 
> displayed all the enviroment variables. I found the above two variables
> were not defined at all. 
> 
> Can anyone give me any suggestions or reasons for this? Thanks a lot.

Sure. Write "Hi! Please tell me your name!" on the page and add a
mailto link so that those who access your page can easily respond.

Another suggestion is to post in the right newsgroup. That has nothing
whatsoever to do with perl, even though you happen to be writing your
code in it.

-- 
		    Calle Dybedahl, UNIX Sysadmin
      qdtcall@esb.ericsson.se  http://www.lysator.liu.se/~calle/


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

Date: Wed, 13 Aug 1997 02:33:09 -0600
From: crr026@email.mot.com
Subject: Problems with split
Message-Id: <871456849.23391@dejanews.com>

Hi!

I have this program:

#!perl
$Line = "one|two|three";
print "$Line\n";
@Atoms = split (/\|/, $Line);
foreach (@Atoms) {
	print "$_\n";
}

which gives this output

one|two|three
one
two
three

I want to store the pattern part of split into a variable. However, the
following try

#!perl
$Line = "one|two|three";
print "$Line\n";
$sep = "\|";
@Atoms = split (/$sep/, $Line);
foreach (@Atoms) {
	print "$_\n";
}

gives me this output

one|two|three
o
n
e
|
t
w
o
|
t
h
r
e
e

Can someone explain what's wrong with my program?

TIA,
Ramesh

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Wed, 13 Aug 1997 02:47:25 -0400
From: "Shane P. Miles" <yngwie@erols.com>
Subject: Script testing
Message-Id: <33F1587C.E029EDF8@erols.com>

    Where can I get a hold of a personal web server so I can try out my
scripts?  I've searched with very little luck.

--
Shane P. Miles
http://members.tripod.com/~malmsteen/index.html




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

Date: Tue, 12 Aug 1997 23:12:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chris Schoenfeld <chris@ixlabs.com>
Subject: Re: SelfLoader and -T
Message-Id: <Pine.GSO.3.96.970812231033.29850Y-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Chris Schoenfeld wrote:

> As following in the preaching of Tom Christiansen, et al, I religiously
> use -Tw in all my scripts. However, I get insecure dependancies within
> the SelfLoader module when I run with this option. Hence, none of my big
> CGI scripts can use SelfLoader.
> 
> Has this been fixed? 

I haven't heard of this being fixed. Unless you hear otherwise, it sounds
like it's worth a bug report. It may not be fixed soon (unless you fix it
yourself :-) but it should at least be put on the list. Thanks! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1997 03:27:42 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Sorting Challenge
Message-Id: <5sr9je$edi$1@info.uah.edu>

In article <5sr14s$ad7$1@info.uah.edu>,
	gbacon@cs.uah.edu (Greg Bacon) writes:
:                     map { /^.*(\d+)\./; [ $_, $1 ] }
:     @names_numbers = map { /^.*(\d+)\./; [ $_, $1 ] } @files;
:     /
:      ^.*    # last occurence of...
:      (\d+)  # a run of digits (stuffed into $1)...
:      \.     # followed by a dot
:     /x

Doh!  EPASTBEDTIME.  As Josh Purinton so kindly pointed out, you should
s/\^\.\*/^.*?/g;

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Tue, 12 Aug 1997 22:00:24 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Stuck on math problem
Message-Id: <808rs5.uer.ln@localhost>

Ranson (ranson@infoave.net) wrote:

: Greetings, I am trying to figure a simple? math equation within a 
: foreach loop.

A while loop works just as well, and does not use temporary
intermediate variables/arrays...


: I know it has to be simple but just can not get the sytax correct.

You have correct syntax. This is always the easy part.

It is the other side of the coin, namely semantics, that give many
programmer's trouble.


: I just need to add any number of items stored in a temp file and
:  produce a 
: total. $total

: In the code below i need to add each $subtotal and produce a $total

: The best I have been able to get is: 12 30 42 60 72 90 - 90 IS the
:  correct total 
: for all $subtotal - but can't get rid of the 12 30 42 60 72


If you had supplied some sample data to try it with, I would have
spent some time trying it out. If I add in the time it would take
to reverse engineer a data set, then it is over the amount of
time I budget per article.

Sorry.


: Any help is appricated. And thanks for all of you who have helped me 
: in the past.

I can offer some help in the time available however.

I believe the comments below will make your program easier to
understand. This is important when you need to come back to it
after not looking at it for a few months.




: open (TEMP, "$path/cgi/tmp/$temp_file");

You should always check the return value from open() calls.

   open (TEMP, "$path/cgi/tmp/$temp_file") || 
      die "could not open '$path/cgi/tmp/$temp_file'  $!";

Especially when doing CGI stuff with the ubiquitous permission
problems that occur in that application domain  ;-)



: @tmplines = <TEMP>;
: close (TEMP);
: foreach $tmpline (@tmplines)

@tmplines is a waste of memory if all you are going to do is
loop through it.

You can loop through the file contents without resorting to sucking
the entire file into memory:

   while (defined($tmpline = <TEMP>) {

Less typing too ;-)



: {

:     ($Item_no, $item_desc, $Item_quan, $Item_cost, $Item_unit) = split(/:/,$tmpline);


Why put them into a hash at all?


:     $tempItem_no{$Item_no}=$Item_no;
:     $tmpItemDesc{$Item_no}=$item_desc;
:     $tmpQuan{$Item_no}=$Item_quan;
:     $tmpCost{$Item_no}=$Item_cost;
:     $tmpUnit{$Item_no}=$Item_unit;

: $subtotal = $tmpQuan{$Item_no} * $tmpCost{$Item_no};

   $subtotal = $Item_no * $Item_cost;  # seems to work.
                                       # Beware of precision/accuracy
                                       # issues if the $Item_cost is
                                       # not an integer amount...


: $total += $subtotal;

:         print "<TR><TD>$tmpItemDesc{$Item_no}</TD>";

:         print "<TD ALIGN=left>&nbsp; &nbsp; &nbsp; $tmpQuan{$Item_no}</TD>";

:         print "<TD ALIGN=left>&nbsp; &nbsp;$tmpCost{$Item_no}</TD>";

:         print "<TD ALIGN=left>&nbsp; &nbsp;$tmpUnit{$Item_no}</TD>";

:         print "<TD ALIGN=left>&nbsp; &nbsp;$subtotal</TD>";

:         print "</TR>$total\n";


Whew! Do you get paid by how many characters are in your 
program or something  ;-)


Doesn't looking at the output from that give you a headache?

Throw a newline in there every now and again.


Too much typing yet again:


print<<ENDHTML;   # this is called a "here-doc", see the perldata man page
<TR><TD>$item_desc</TD>
<TD ALIGN=left>&nbsp; &nbsp; &nbsp; $Item_quan</TD>
<TD ALIGN=left>&nbsp; &nbsp;$Item_cost</TD>
<TD ALIGN=left>&nbsp; &nbsp;$Item_unit</TD>
<TD ALIGN=left>&nbsp; &nbsp;$subtotal</TD>
</TR>$total
ENDHTML
: 	
:  } # End of foreach


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


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

Date: Wed, 13 Aug 1997 00:23:55 GMT
From: ccboone@amber.indstate.edu (Charles Boone)
Subject: Time problem.
Message-Id: <33f0fdf6.6883546@news.indstate.edu>

I am using perl to gather some info from wtmp.  I just happened to
notice that when I convert the login time it gives me the wrong month
ex. 7 for Aug instead of 8.  I was wandering if there is a bug in
5.003 or what.  Please email me ccboone@amber.indstate.edu


Charles Boone
Unix System Administrator  -- Indiana State University


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

Date: Tue, 12 Aug 1997 23:04:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Charles Boone <ccboone@amber.indstate.edu>
Subject: Re: Time problem.
Message-Id: <Pine.GSO.3.96.970812230123.29850W-100000@julie.teleport.com>

On Wed, 13 Aug 1997, Charles Boone wrote:

> I am using perl to gather some info from wtmp.  I just happened to
> notice that when I convert the login time it gives me the wrong month
> ex. 7 for Aug instead of 8.  I was wandering if there is a bug in
> 5.003 or what.  

This should be in the FAQ, but I couldn't find it in section 4, in the
section about dates. But it's in the perlfunc(1) manpage in the sections
about localtime and gmtime, where it says:

    All array elements are numeric, and come straight out of a struct tm. 
    In particular this means that $mon has the range 0..11 and $wday has
    the range 0..6. 

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1997 02:03:45 GMT
From: twv@rose.hp.com (Terry von Gease)
Subject: typeglob in perl 4 and 5
Message-Id: <5sr4m1$8nh$1@rosenews.rose.hp.com>


Is there some sort of change to the way typeglobs are handled from
perl 4 to perl 5?

In perl 4 I could say something like...

  $hash{'abc'}="some data";

  foreach (@list) {
    &myfunct(*hash);
  }

  sub myfunct {
  local(*scrap)=@_;

  $val=$scrap{'abc'};

  }

And the value of $val in myfunct would indeed be set to "some data".

If I try this with perl5, the %scrap array in myfunct is empty, as in
null.

In order to make it work in perl5 i have to add a line in the foreach
loop...


  $hash{'abc'}="some data";

  foreach (@list) {
    local(*hash)="hash";  #### add this line to make it work
    &myfunct(*hash);
  }

  sub myfunct {
  local(*scrap)=@_;

  $val=$scrap{'abc'};

  }

I don't want any lectures on the inherent dangers of using a typeglob
outside of a local(), I have my reasons and I'm not in the least bit
interested in reasons why I shouldn't do this. What I am interested
in is finding out if the perl5 (5.003 actually) is broken or does it
actually work this way now.

If this is the way it works now I have to vet many cubic
yards of perl scripts, a task in which my disinterest approaches
total.

If this isn't the way it's supposed to work, when and where is it fixed?


twv@rosemail.rose.hp.com

--
Terry                     You'll get further with a smile and a gun
			  than just a smile.


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

Date: Tue, 12 Aug 1997 23:26:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Terry von Gease <twv@rose.hp.com>
Subject: Re: typeglob in perl 4 and 5
Message-Id: <Pine.GSO.3.96.970812231937.29850a-100000@julie.teleport.com>

On 13 Aug 1997, Terry von Gease wrote:

> Is there some sort of change to the way typeglobs are handled from
> perl 4 to perl 5?
> 
> In perl 4 I could say something like...
> 
>   $hash{'abc'}="some data";
> 
>   foreach (@list) {
>     &myfunct(*hash);
>   }
> 
>   sub myfunct {
>   local(*scrap)=@_;
> 
>   $val=$scrap{'abc'};
> 
>   }
> 
> And the value of $val in myfunct would indeed be set to "some data".

Not unless you put something into @list. Once I do that, it does what I
think you want in my tests under 5.004 and other versions I have sitting
around. 

> If I try this with perl5, the %scrap array in myfunct is empty, as in
> null.

That's what I get when @list is empty, but that's what I'd expect
to get. :-)

> In order to make it work in perl5 i have to add a line in the foreach
> loop...

>   foreach (@list) {
>     local(*hash)="hash";  #### add this line to make it work
>     &myfunct(*hash);
>   }

That doesn't make any difference in my tests, but maybe I'm missing
something. I think one of us is. :-)

Seriously, if you can come up with a script which works in version 4 but
not in 5, and if the reason isn't already documented in the perltrap(1) 
manpage, please submit it with perlbug.

> I don't want any lectures on the inherent dangers of using a typeglob
> outside of a local(), I have my reasons and I'm not in the least bit
> interested in reasons why I shouldn't do this. 

Okay. Lecture available upon request. :-)

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/




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

Date: Tue, 12 Aug 1997 23:09:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Matthew Wagley <rudedog@pld.com>
Subject: Re: Using perl noninternet, stand alone for processing!!????????!!!!
Message-Id: <Pine.GSO.3.96.970812230505.29850X-100000@julie.teleport.com>

On 12 Aug 1997, Matthew Wagley wrote:

>   I am wanting to use perl on my system at work to compile and tear down
> *.txt files.  I can not find any resource to this effect on the net. 
> All of the relate to perl for the internet on using it on your site or
> pages. 

Most uses of Perl aren't for the web. (But most things on the web use Perl
in some way.) 

> I want to use this at work.  I have read books and such, still a newbie,
> but I can't figure out the /usr/page/  blah blah blah to turn into terms
> that my windows95 or DOS can understand instead of for Unix.  

You may want to get the new Learning Perl book, which is now available in
a Windows flavor. 

    http://www.ora.com/catalog/lperl2/noframes.html
    http://www.ora.com/catalog/lperlwin/noframes.html

>   Your help is appreciated very much.

Perl can be used for what you're talking about. If you have more questions
about Perl which aren't answered in the FAQs and docs, please post those
questions here. Hope this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 Aug 1997 17:46:28 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Using perl noninternet, stand alone for processing!!????????!!!!
Message-Id: <44pqs5.61g.ln@localhost>

Matthew Wagley (rudedog@pld.com) wrote:
:   I am wanting to use perl on my system at work to compile and tear down
: *.txt files.  

That is what most Perl programming is used for.

CGI accounts for way less than half of all the Perl programming that
goes on.

Perl was even in pretty wide use before the WWW was even invented...


: I can not find any resource to this effect on the net.  


There are *hundreds* of pages of free documentation that is included
with the perl distribution. That would be a good start.


: All
: of the relate to perl for the internet on using it on your site or pages. 
: I want to use this at work.  I have read books and such, still a newbie,
: but I can't figure out the /usr/page/  blah blah blah to turn into terms
: that my windows95 or DOS can understand instead of for Unix.  


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


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

Date: 13 Aug 1997 04:40:19 GMT
From: "Matthew Wagley" <rudedog@pld.com>
Subject: Using scripts and such off of browser off line???
Message-Id: <01bca7b3$523ac8a0$9823fdce@matthews>

  Can I write scripts and such and have them produce results without being
connected to the internet and such??  I am wanting people to use a browser
at work to view files, but , I want a script to read the file they want and
do its thing to this file so they can view it on the browser and such.  ???
confused?? we'll it's hard to explain, maybe not.
Can I use scripts as long as I have perl on the machines???
Thanks in advance.
and thanks to all that answered my previous question.
Thanks.
Matthew Wagley


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

Date: Tue, 12 Aug 1997 22:56:25 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Aaron D Newman <newman@ttd.teradyne.com>
Subject: Re: What is the littlest Perl?
Message-Id: <Pine.GSO.3.96.970812225241.29850U-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Aaron D Newman wrote:

> We have need for a command interperter in an embedded application.  I
> was considering stripping down Perl so that it just has regexp's and a
> few of the primitives.  I was wondering if anyone else has experience
> stripping down Perl, and what the tinieist executable space you could
> get it down to (roughly).

Why strip it down? You can link to Perl from your application, and have
_all_ of Perl! Check out the mod_perl module for embedding Perl in the
(very popular) Apache webserver for an example of how to do this.

    http://www.perl.com/CPAN/

Hope this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

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

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