[11859] in Perl-Users-Digest
Perl-Users Digest, Issue: 5459 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 22 19:07:31 1999
Date: Thu, 22 Apr 99 16:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 22 Apr 1999 Volume: 8 Number: 5459
Today's topics:
AIX4.3, perl5.004, and "waitpid"? <dme7@cornell.edu>
Re: Ansi Characters in Perl <swolfington@home.com>
Re: cheap perl scripts <jonesy@rmi.nospam.net>
Re: cheap perl scripts vnguyen2891@my-dejanews.com
Database file locking... <Not@gonna.tell>
Re: Database file locking... <tchrist@mox.perl.com>
Re: Generating a unique string for order number (Daniel Beckham)
Re: Help! Error message when using C-comment stripper f <aqumsieh@matrox.com>
HELP: opening files in perl and streaming them to web p <stats123@my-dejanews.com>
Re: How to change an array to a list? yong321@yahoo.com
Re: How to read the modification date of a file? (Abigail)
Re: http related module ? <cassell@mail.cor.epa.gov>
Re: Illegal seek (this makes no sense to me =) <emschwar@rmi.net>
Re: Illegal seek (this makes no sense to me =) (Clinton Pierce)
mod_perl vs. compiled perl? (Aaron Weiss)
Module Questions <robsmith@yahoo.com>
Re: Need to parse exported table from access <cassell@mail.cor.epa.gov>
Re: newbie with a "howto" question <jglascoe@giss.nasa.gov>
Re: newbie with a "howto" question <tbriles@austin.ibm.com>
Re: newbie with a "howto" question (Randal L. Schwartz)
Re: NT/Processes/IDs <perin@panix7.panix.com>
Re: passing 2 arrays into... <jglascoe@giss.nasa.gov>
Re: passing 2 arrays into... <cassell@mail.cor.epa.gov>
passing an array as a parameter <greg2@surfaid.org>
Performance And Preallocating Arrays james.p.williams@usahq.unitedspacealliance.com
RE: Perl-Users Digest, Issue: 5454 Volume: 8 (SANTOS JASON M)
Reading in password from <STDIN> <mgcook@ic.delcoelect.com>
Re: Reading in password from <STDIN> <cassell@mail.cor.epa.gov>
Re: remove space (Daniel Beckham)
Re: remove space <aqumsieh@matrox.com>
Re: Script to tidy/format a C file (Bart Lateur)
Re: Script to tidy/format a C file <carlj@peak.org>
Re: Small problem, please help (regarding upload) (Bob Trieger)
Re: The Future of Tk? <oakley@channelpoint.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Apr 1999 22:31:25 GMT
From: Doug Elias <dme7@cornell.edu>
Subject: AIX4.3, perl5.004, and "waitpid"?
Message-Id: <7fo7vt$irf$20@newsread.f.de.uu.net>
G'day ...
I have a piece of code that runs fine under Solaris6/perl5.005_02, but
when I run it under AIX4.3/perl5.004 it doesn't work properly, and the
problem statement involves a non-blocking "waitpid" which apparently
isn't receiving notification of the termination of the child process...
is this a known problem for that implementation-mix? I've asked that
the latest version of perl be obtained and installed, but I'm just
trying to verify the actual problem.
Thanks,
doug
--
Doug Elias, Ph.D.
__|_ Internet: doug@research.johnson.cornell.edu
dr _|_)oug USmail: Director of Technology
(_| Parker Center/Johnson Grad. School of Mgmt.
(_|__lias 302 Sage Hall/C.U./Ithaca/N.Y./14853-6201
| Phone: 607-255-3521 Fax: 607-254-4590
------------------------------
Date: Thu, 22 Apr 1999 20:59:39 GMT
From: "Scott W" <swolfington@home.com>
Subject: Re: Ansi Characters in Perl
Message-Id: <%4MT2.758$hl3.2092@news.rdc2.occa.home.com>
I got it. I was trying Chr(99) and it should have
been chr(99). Duuhhh.
Scott
Scott W <swolfington@home.com> wrote in message news:...
> Hi!
>
> How do I reference ANSI characters in Perl? For instance, the ANSI
> character
> for the letter C is 99. Thanks!
>
> Scott
>
>
>
------------------------------
Date: 22 Apr 1999 21:53:19 GMT
From: Jonesy <jonesy@rmi.nospam.net>
Subject: Re: cheap perl scripts
Message-Id: <7fo5of$rk5$2@news1.rmi.net>
pejman@pejman.com wrote:
: I am looking for somebody, who can write me some small perl scripts
: for small amount of money. Please let me know if you are interested
: or if you know somebody who is willing to do that.
Sounds like the end of another semester is nigh. :-)
Jonesy
--
253 days to go until the Year 2000 -- So what!
619 days to go until the 3rd Millennium of the C.E.
------------------------------
Date: Thu, 22 Apr 1999 22:17:38 GMT
From: vnguyen2891@my-dejanews.com
Subject: Re: cheap perl scripts
Message-Id: <7fo75t$bcd$1@nnrp1.dejanews.com>
Hi,
I can do that if you want. I currently get a little bit of free times. Please
contact me through vnguyen_1999@yahoo.com
Thanks
Van Nguyen
In article <372f40c2.3349313@nntp.best.com>,
pejman@pejman.com wrote:
> Hi,
>
> I am looking for somebody, who can write me some small perl scripts
> for small amount of money. Please let me know if you are interested
> or if you know somebody who is willing to do that.
>
> (please reply to my email-address)
>
> Thanks in advance,
> Pejman
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Apr 1999 22:31:24 GMT
From: "Doug Crabtree" <Not@gonna.tell>
Subject: Database file locking...
Message-Id: <7fo7vs$irf$19@newsread.f.de.uu.net>
I have a couple of functions written that will open a database file and
read/write data to it. I also have a function that will pack the data to
minimize the file after deletions and changes are made (run once in a blue
moon). My question is, using MLDBM, do I have to worry about two users on a
web site reading/writing from this file at the same time?
This is being done on a UNIX machine.
TIA,
Dug
------------------------------
Date: 22 Apr 1999 22:31:27 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Database file locking...
Message-Id: <7fo7vv$irf$23@newsread.f.de.uu.net>
In comp.lang.perl.misc, "Doug Crabtree" <Not@gonna.tell> writes:
:My question is, using MLDBM, do I have to worry about two users on a
:web site reading/writing from this file at the same time?
Private reply sent via email to avoid clogging newsgroup. Enjoy.
--tom
--
I'm sure that that could be indented more readably, but I'm scared of
the awk parser. --Larry Wall in <6849@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Thu, 22 Apr 1999 17:16:58 -0500
From: danbeck@scott.net (Daniel Beckham)
Subject: Re: Generating a unique string for order number
Message-Id: <MPG.11895bd2db3492a29896b9@news.idt.net>
I know this isn't a real answer, but why bother using a random id? Why
not just use an incremented ID number that is unique? Start with, say...
1000 and just increment for each one... If you are using a hash to store
the already used numbers, it's pretty easy to check for an existing id...
In article <371E7FFB.55FB2A33@well.com>, gregm@well.com says...
> I'm working on an e-commerce application where I would like to generate a
> unique, mostly numeric string for a new order number.
>
> Here are some of the possibilities I have considered. I don't think that any of
> these alone are sufficient but combining two of them may give me something close
> to what I want. I would appreciate any suggestions or insights into this
> problem.
>
> time - I think this is a good start, but not to be used alone since two
> customers may submit an order at the same time (within the same second).
>
> rand - May be good concatenated with time. I'm a little afraid of creating a
> duplicate order number one in a gazillion times though.
>
> ip address - Bad. Users behind a firewall may all have the same apparent ip
> address.
>
> $$ (process id) - May be good concatenated with time. It's especially nice on a
> *nix system, since it returns numbers that don't repeat for a long time. On my
> NT system though, it is a pattern that repeats within 10-20 numbers.
>
> Thanks,
>
> Greg
>
>
------------------------------
Date: 22 Apr 1999 22:31:26 GMT
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Help! Error message when using C-comment stripper from perlfaq
Message-Id: <7fo7vu$irf$22@newsread.f.de.uu.net>
GoodfriB@jntf.osd.mil (James R. Goodfriend) writes:
> When I run this using -w I get the following error message:
>
> Use of uninitialized value at (program) line 19, <CFILE> chunk 1.
>
> ...this shows up about 20 times. Can anyone tell me what I can do to
> suppress this damn message? It's driving me slowly insane...
I have a wacky idea. Find out what variable(s) you're trying to access
on line 19 and is/are undefined, and fix your code.
Another idea would be to turn off the monitor.
------------------------------
Date: 22 Apr 1999 22:31:21 GMT
From: Matt Evans <stats123@my-dejanews.com>
Subject: HELP: opening files in perl and streaming them to web pages
Message-Id: <7fo7vp$irf$15@newsread.f.de.uu.net>
Hi,
I'm trying to open files in perl which are outside the web tree being served,
and stream themstraight to a web page in the hope it will pop up a "save as"
box and people will be able to download these files.
I have sort of got it working but it's very buggy.
I'm running apache on Win95 with active state perl.
Heres the code I have written:
#!C:/perl/bin/perl.exe
open(DFILE, "C:\\My Documents\\webmaster\\stds_down\\files.txt")||&errprn
("Couldn't open Download file: $dfile");
print "Content-type: application/octet-stream\n\n";
while ($line = <DFILE>)
{
print $line;
}
close(DFILE);
this seems to work but if I change the file to open from a text file to a jpg
say, and I change the Content-type to image/jpeg te whole thing stops working.
Please someone help me.
Cheers,
Matt
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Apr 1999 22:31:22 GMT
From: yong321@yahoo.com
Subject: Re: How to change an array to a list?
Message-Id: <7fo7vq$irf$17@newsread.f.de.uu.net>
> > if ($email =~ / /)
> > { @email = split / /,$email;
> > $smtp->to(@email); #doesn't seem to work
>
> How does it not seem to work? What does @email contain at this point?
Excuse me. It was my fault. I passed the original $email, that is, "a@b.com
c@d.com" to the mail() method: $smtp->mail($email). In this case, I should say
$smtp->mail($email[0])
after @email is created by the split. Sorry.
Yong
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Apr 1999 22:31:26 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to read the modification date of a file?
Message-Id: <7fo7vu$irf$21@newsread.f.de.uu.net>
howitgolook (howitgolook@my-dejanews.com) wrote on MMLX September
MCMXCIII in <URL:news:7fnman$qgl$1@nnrp1.dejanews.com>:
-- How can I determine the modification date of a file on a remote server?
You NFS mount the disk and use the stat() command.
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: 22 Apr 1999 22:31:20 GMT
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: http related module ?
Message-Id: <7fo7vo$irf$13@newsread.f.de.uu.net>
Ching-Yu Lin wrote:
>
> hello,
> I want to write a WWW client application in perl.
> Are there any http module I can use ?
> Or any sample code to refer to ?
> thanks in advance ,
There are lots of modules, all available at CPAN. But I
can't tell what you are asking for.
Do you want to write Perl code to run on a webserver? If so, look
into CGI.pm
Do you want an HTTP daemon? Do you want HTTP content negotiation?
HTTP status code processing? All these things are available too,
under the HTTP:: hierarchy on CPAN.
HTML? still on CPAN
WWW API interface? ditto
Without more specifics, we can't help you more.
And your question may not really be relelvant to this newsgroup,
even though you want to program in Perl. It depends on the topic.
One of the comp.infosystems.www.* newsgroups might in fact be
more appropriate.
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: 22 Apr 1999 15:19:52 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Illegal seek (this makes no sense to me =)
Message-Id: <xkf3e1sic93.fsf@valdemar.col.hp.com>
phukit@enteract.com writes:
> Attitude aside, thank you. =) This helped me get the right answer. I was
> looking in the camel book, but I evidently glossed over the relevant part.
The camel book suffers from being in print, and thus, out of date more or
less as soon as it hits the shelves. This is why you should always
consult the online documentation, which is kept up-to-date WRT the
version of perl it shipped with. I was about to add "...if you're not
sure about what the book says," but I remembered that in some cases, the
book is just not going to have any information at all.
perldoc is your friend. It's free, it's easy, and it's much faster than
waiting for newsgroup replies.
-=Eric
------------------------------
Date: 22 Apr 1999 22:31:29 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Illegal seek (this makes no sense to me =)
Message-Id: <7fo801$irf$25@newsread.f.de.uu.net>
[poster cc'd in e-mail]
On 22 Apr 1999 17:10:00 GMT, phukit@enteract.com wrote:
>Clinton Pierce <cpierce1@ford.com> wrote:
>> Unless the open() fails, the contents of $! are indetermininate. Don't
>> use $! to test the success or failure of UNIX system calls.
>
>It doesn't outright fail, but when it closes <SENDMAIL> /usr/sbin/sendmail
>never gets run. That "Illegal Seek" error is the only indication I have
>that something happens between the open and close.
Welcome to UNIX. :-)
The exit status of the open only indicates that the fork() preceeding the
exec() of shell to run the pipeline is successful. Once the fork()
happens, the perl interpreter has no way of knowing what happened to the
pipeline...
...until you close the filehandle. At that time perl does a wait() on the
child that it forked off earlier. The wait will tell perl if the pipeline
did the right thing.
So oddly, to see if a pipeline worked, you need to check the exit status
of the open() AND the close(), examining $! and $? where appropriate.
For more information: see open() and close() in the Blue Camel, chapter 3;
the Perl Cookbook; or the manual pages for perlfunc and perlipc.
Remember though: $! gets set to all kinds of crazy things in perl which
aren't necessarily important except immediately after a system call
failure. To see this try:
perl -MTest -e 'print $!'
$! was set even though nothing went wrong. Don't rely on its value unless
you're using it immediately after a system-call _failure_-- like you're
supposed to.
--
Clinton A. Pierce "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org Miracles." -- Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: Thu, 22 Apr 1999 21:23:15 GMT
From: aaron@pobox.com (Aaron Weiss)
Subject: mod_perl vs. compiled perl?
Message-Id: <371f91de.10757676@newsstand.cit.cornell.edu>
Hi,
This is my first time deploying a production server which is mainly a
database search engine; that is, the majority of hits to this site
will be lookup requests. The lookup requests are processed via CGI
using Perl, which translates them into SQL, sends the query to the
database, receives the results, formats the results into HTML output
and delivers them back to the user.
It all works fine ... but I am now trying to understand the most
efficient (CPU time and RAM) to handle all this.
mod_perl, which I have been using, works well to reduce start-up time
of the scripts but it costs a lot, it seems, in memory: each request
spawns a child process, and a mod_perl child can be very large since
the apache executable with mod_perl compiled in is quite a bit larger
than the "vanilla" apache.
I've been wondering about compiled perl, which comes with Perl 5.005
-- would there be a memory advantage to compiling the Perl scripts
into C code and using the vanilla apache to trigger the requests? I
figure this would save RAM from child-spawning, but maybe I am missing
something?
Any other suggestions for efficiency when running a server which
accepts many web-based database lookup requests handled with Perl
scripts?
thanks!
Aaron
------------------------------
Date: Thu, 22 Apr 1999 18:00:25 -0500
From: Robert Smith <robsmith@yahoo.com>
Subject: Module Questions
Message-Id: <371FAA09.D6420228@yahoo.com>
I would like to implimnet the Apache-SSI-2.06.tar.gz fround at
ftp://ftp.digital.com/pub/plan/perl/CPAN/authors/id/KWILLIAMS/ but my
question is how do I do it?? Isthere some sort of install for it??
Where do I install it to and then how do I get PERL to use it??
Thanks
Robert
------------------------------
Date: 22 Apr 1999 22:31:28 GMT
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Need to parse exported table from access
Message-Id: <7fo800$irf$24@newsread.f.de.uu.net>
Pamela Goldfarb wrote:
>
> I am storing an exported access table on my web server. It is an ascii file
> with comma delimited fields and with strings enclosed with "".
Ah. Standard CSV - comma-separated values.
> The strings can contain commas, quotation marks, and new-lines. There can
> also be blank fields.
>
> Example (each data record, has three fields: a numeric, followed by a
> string, followed by a numeric)
>
> 123, "abc", 456,
> 124, "first word then
> newline", 888,
> 125, "first word ""quoted"" end
> ,,,", 999
>
> I want to create a perl script that can parse this data into an array of
> fields that can then be searched, processed, etc. and the outputted to a
> html file.
>
> I am having trouble constucting the appropriate parsing code. In particular
> the fact that there may be multiple lines in the datafile that make a whole
> data line.
Go to CPAN and get the Text::CSV module, which should do what you want.
http://www.perl.com/CPAN/
should get you to the archive of huge numbers of useful Perl modules.
And you may be interested in reading section 6 of the FAQ, on regular
expressions. It has several answers that relate to your problem,
including:
"I'm having trouble matching over more than one line. What's wrong?"
Can I use Perl regular expressions to match balanced text?
> Since this is MS Access outputted data, I would think that perl code to do
> what I want already exists, can someone
> point me to where I can find such code?
Actually, Perl [and many Perlites] tend to be unix-centric, rather
than Bill-centric. But CSV is common enough that there are now
tools for coping with it.
You may also want to look into Perl's ODBC features, since you're
on a WinTel system. And Perl's DBI which lets you have a uniform
interface to a wide variety of databases.. including MS Access.
HTH,
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Thu, 22 Apr 1999 18:13:37 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: derose@my-dejanews.com
Subject: Re: newbie with a "howto" question
Message-Id: <371F9F11.E9EA605C@giss.nasa.gov>
[posted and cc'd]
derose@my-dejanews.com wrote:
>
> cat $file1 | sort | uniq > $outfile
useless use of cat.
I admire your sense of laziness. As such, I give you this:
print STDOUT sort keys %{ @hash{<ARGV>} = FOO => \%hash };
Jay Glascoe
------------------------------
Date: 22 Apr 1999 22:31:23 GMT
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: newbie with a "howto" question
Message-Id: <7fo7vr$irf$18@newsread.f.de.uu.net>
derose@my-dejanews.com wrote:
> Hello,
>
> I'm new at Perl, and don't really have the patience's to find the answers in
> my books, so I thought I would ask some experts.
<snipped questions>
> If any one could point me in the correct direction, I would appreciate it.
I would be *shocked* if one of the experts that read this group gives you a
straight answer.
This group is not here to regurgitate documentation that is readily available to
every Perl user.
Try:
perldoc perldoc
perldoc perltoc
and start reading.
- Tom
------------------------------
Date: 22 Apr 1999 15:35:04 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: newbie with a "howto" question
Message-Id: <m1d80w473b.fsf@halfdome.holdit.com>
>>>>> "Jay" == Jay Glascoe <jglascoe@giss.nasa.gov> writes:
Jay> [posted and cc'd]
Jay> derose@my-dejanews.com wrote:
>>
>> cat $file1 | sort | uniq > $outfile
Jay> useless use of cat.
Jay> I admire your sense of laziness. As such, I give you this:
Jay> print STDOUT sort keys %{ @hash{<ARGV>} = FOO => \%hash };
Useless use of FOO (that's the value for the first key, and none of
the rest). :) This is just as good:
print sort keys %{{map {$_, 1} <>}};
print keys %{{"Just another Perl hacker,","or something like that"}};
--
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: 22 Apr 1999 18:25:09 -0400
From: Lewis Perin <perin@panix7.panix.com>
Subject: Re: NT/Processes/IDs
Message-Id: <pc74sm8xph6.fsf@panix7.panix.com>
Susanne Schmidt <banshee@zedat.fu-berlin.de> writes:
> Hello all,
> i have to solve a problem under Win-NT within a perlscript: a perlscript
> should be scheduled from "at" at xx o`clock - but only if the run before
> is not still running. I can`t calculate the time for one script-run, so i
> have to look for the running process - how to do that under NT ?! (i just
> know UNIX..) Is there any module for showing running processes ? Does NT
> have processes ? ;) can i get them as a list? send signals ? GET AN ID ? :)
>
> Maybe it`s the complete wrong idea - where do i have to look ?
>
> Thank you for any idea!
I don't think you really mean process IDs, for each instance of your
script will have a different ID.
If you want to find your program's name in the output of ps, there's a
serviceable NT version of ps in the package of free (but not open
source) Unix utilities for NT at
<http://maxx.mc.net/~jlh/nttools.htm>. There's actually a version of
cron that works well there.
You might want to explore NT's native synchronization primitives, but
I doubt it from what you've said.
Cheers, Lew
------------------------------
Date: Thu, 22 Apr 1999 16:46:51 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: hallian@hotmail.com
Subject: Re: passing 2 arrays into...
Message-Id: <371F8ABB.42BE3075@giss.nasa.gov>
hi,
First of all:
perldoc perlref
perldoc perlreftut
hallian@hotmail.com wrote:
>
> sub routine_main {
> statements....
> statements....
> statements....
> &routine_two(@array1,@array2)
# pass your arrays as references using the reference
# operator "\":
routine_two(\@array1, \@array2);
> }
>
> sub routine_two {
> local(@newarray1,@newarray2)=(?,?)
bleah! don't use local! It's weird, it's effects are
hard (or impossible) to see just by looking at your
program text. Use "my()" instead:
my ($ra_ref_one, $ra_ref_two) = @_;
# from here, you could simply use the array refs
# like "$ra_ref_one->[0]" or "pop @$ra_ref_two"
# but I think dereferencing immediately is easier
# to grok:
my @ra_one = @$ra_ref_one;
my @ra_two = @$ra_ref_two;
> statements....
> statements....
> statements....
> }
Jay Glascoe
--
"'We promise, yes I promise!' said Gollum. 'I will serve
the master of the Precious. Good master, good Smeagol,
*gollum*, *gollum*!' Suddenly he began to weep and bite
at his ankle again."
-- J.R.R.T.
------------------------------
Date: Thu, 22 Apr 1999 14:28:12 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: passing 2 arrays into...
Message-Id: <371F946C.44B04F26@mail.cor.epa.gov>
hallian@hotmail.com wrote:
>
> hi perlers....
perlers? Isn't that as in alt.knitting?
> I need to pass two array from one sub routine, into another subroutine. The
> array values are dynamic and keep be called by different routines. But I need
> to pass them as two array and then read into 2 new arrays. For example
>
> [snip]
>
> How can I read @array1 into @newarray1 and @array2 into @newarray2;
Pass them as references.
This is a FAQ. So you can use perldoc to find it. Or go to
perlfaq7 and read the question/answer titled:
"How do I pass/return a { ... Array ... }?"
It has the answer, as well as pointers to other Perl docs chockful of
useful info on this subject.
In future, please remember. This newsgroup expects posters to do
their homework first before posting.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Thu, 22 Apr 1999 23:34:55 +0100
From: Greg Griffiths <greg2@surfaid.org>
Subject: passing an array as a parameter
Message-Id: <371FA40F.3CA652B3@surfaid.org>
Dear All,
since the original query below I've got the array to work, I just now
need to work out how to pass it as a parameter to another CGI PERL
script, preferably using a HTML FORM submission :
@stuff is made up of $name and $email
WINDOWS PERL SCRIPT
build list of people we are going to mail
display a list on the screen
do send_mail($subject,$userid,$message,@stuff) preferably using a FORM
submission
RECEIVING UNIX SCRIPT
for each Name in Stuff
send the following to $email using sendmail
subject=$subject
" Dear $NAME \n $message \n"
end
<form name="return" action="http://www.aber.ac.uk/cgi-bin/main.pl"
method="post">
<input type="hidden" value="$userid" name="userid">
<input type="submit" value="return">
</form>
hope that this clarifies my problem.
Thanks for you help.
Original query below
Dear All,
I've just been forced into a corner over the use of the mailserver for
my project, i.e. I must use the Unix SendMail command for my project due
to server security issues, however my system using the Windows ODBC.pm
package. So I am going to call the send mail routine on teh server from
a Windows server, to do this I need help.
Firstly I will need to place each 'real name' and 'email address' in an
array and pass that over to this script and then sort through them on
the other side and do a send cycle for each. The array will be passed
along with other strings for the subject and the message, so could you
indicate how I'd get more than one argument sorted. I'll need to send
them as parameters from a submitted form, to avoid other security
problems.
Any help getting the array interaction to work appreciated.
------------------------------
Date: Thu, 22 Apr 1999 21:53:19 GMT
From: james.p.williams@usahq.unitedspacealliance.com
Subject: Performance And Preallocating Arrays
Message-Id: <7fo5od$9tq$1@nnrp1.dejanews.com>
I'm building a large array by pushing new items onto the end as I get them. I
don't know up front how large the array needs to be. For the sake of
performance, I preallocate the array with a guess as the Camel recommends,
my(@a);
$a[100_000]=0;
However, doing this, I can no longer ask the array for its length, requiring
me to keep track of it myself.
if (@a) ... #returns true even though nothing's _really_ there
if ($#a >= 0) #similar
Can I avoid having to keep track of the length myself by shifting the dummies
out of the array, or will this free the memory I preallocated?
shift @a while (@a);
Is there a better way?
TIA,
Jim
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Apr 1999 14:17:53 -0700
From: jmsantos@srpnet.com (SANTOS JASON M)
Subject: RE: Perl-Users Digest, Issue: 5454 Volume: 8
Message-Id: <037164847588D111B5D600600858CDD604DA98B8@srp.gov>
> Date: Thu, 22 Apr 1999 17:45:53 GMT
> From: bernie@fantasyfarm.com (Bernie Cosell)
> Subject: Re: FAQ 4.15: How do I find yesterday's date?
> Message-Id: <371f5ef9.148585779@news.supernews.com>
>
> Tom Christiansen <perlfaq-suggestions@perl.com> wrote:
>
> }
> } $yesterday = time() - ( 24 * 60 * 60 );
>
> This isn't quite correct. There is an ugly-to-program-around problem
> dealing with daylight savings time. The problem is fairly
> limited: only
If you lived in beautiful Arizona, it wouldn't matter :)
> /Bernie\
> --
> Bernie Cosell Fantasy Farm Fibers
> bernie@fantasyfarm.com Pearisburg, VA
> --> Too many people, too few sheep <--
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Are you *that* lonely? :P
--
Jason M. Santos - Unix Sysadmin - Alternative Resources Corp
Currently consulting: Salt River Project - Phoenix, AZ USA
em: jmsantos@srpnet.com ph: +1 602 236 5155
PGP FP: CFFA C31D 8D95 8BF3 1D1A A5EB FC52 4117 27FB A6B0
------------------------------
Date: 22 Apr 1999 22:31:22 GMT
From: "Micah G. Cook" <mgcook@ic.delcoelect.com>
Subject: Reading in password from <STDIN>
Message-Id: <7fo7vq$irf$16@newsread.f.de.uu.net>
I have looked through several man pages and dont see
anything in my only "Learning Perl" book.
I want to read in a users password from <STDIN> but
want to display ****'s while they type it in.
Right now it displays what they type. <-Bad
Apologies if this has been posted before, where do the
post go after they runoff? Is there an archive of post
somewhere? -Micah
I need some more books.
------------------------------
Date: Thu, 22 Apr 1999 14:19:53 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Reading in password from <STDIN>
Message-Id: <371F9279.B2E0783E@mail.cor.epa.gov>
Micah G. Cook wrote:
>
> I have looked through several man pages and dont see
> anything in my only "Learning Perl" book.
I take it you didn't do a thorough search of the FAQ, or
use `perldoc'.
> I want to read in a users password from <STDIN> but
> want to display ****'s while they type it in.
> Right now it displays what they type. <-Bad
Yup. A Bad Thing.
Go to perlfaq8 and read:
"How do I ask the user for a password?"
Or better yet, leanr to use the handy perldoc program.
Type `perldoc perldoc' at the command line to learn
about the nifty features.. including the -q switch which
lets you search the FAQ for key words. Like this:
perldoc -q password
> Apologies if this has been posted before, where do the
> post go after they runoff? Is there an archive of post
> somewhere? -Micah
In this newsgroup it is considered important to do one's
homework before posting.
And yes, there is an archive you can go search. It's
called DeajaNews, and it's on the web.
> I need some more books.
Perhaps. But you can increment your knowledge without
decrementing your wallet. Perl comes with more on-line
pages of info than you would want to count. Type
`perldoc perl' to get a list of the Perl manpages that
come with your installation. Read them in that order,
to reduce your need to keep looking ahead for explanations.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Thu, 22 Apr 1999 17:17:49 -0500
From: danbeck@scott.net (Daniel Beckham)
Subject: Re: remove space
Message-Id: <MPG.11895c05118de0ff9896ba@news.idt.net>
take a look at the perlop section of the perl documentation...
In article <yJyT2.5907$8m5.8839@newsr1.twcny.rr.com>, dbws@----nospam----
hotmail.com says...
> How do you remove all spaces from a string?
>
> Example...
>
> Convert: $string = " remove all spaces ";
> To: $string = "removeallspaces";
>
> Thanks a lot for any help.
>
> Dan Burke
>
>
>
>
>
------------------------------
Date: Thu, 22 Apr 1999 16:37:31 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: remove space
Message-Id: <x3yhfq8l7ck.fsf@tigre.matrox.com>
"Dan Burke" <dbws@----nospam----hotmail.com> writes:
> How do you remove all spaces from a string?
Do tabs and newlines count as spaces?
If so then:
$string =~ tr/\t\n //d;
else:
$string =~ tr/ //d;
------------------------------
Date: Thu, 22 Apr 1999 21:05:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Script to tidy/format a C file
Message-Id: <372188db.1912927@news.skynet.be>
Myke wrote:
>I've exhausted pretty much every avenue I could think of in searching for a
>script which would tidy/format a C file. Maybe I've been looking in the wrong
>places so I thought I'd ask here if anyone knew of such a thing (it doesn't
>have to be a Perl script either).
>
>If it doesn't exist then I may take this opportunity to learn Perl and write
>the script myself. But before I do so I wanted to ask if such a script already
>existed, and also, can Perl handle such a task?
I've always thought Perl would be an excellent tool to write compilers
in (or is that "parsers"). So it probably can be done.
But you really ought to use compiler technology (Bison/Yacc) to tackle
this problem. Done this way, this could prove to be not even that
complicated. After all, the formal specification for Ansi C is not more
than a few pages. (Er... under 800 lines; the Yacc file is around 8k.)
Parse the C source, and while parsing, output it again in a new format.
Duh...
I can distinctly remember there was a tool available (source code) that
does something very much like this. The "C Beautifier" (or is it a
"pretty printer") was even included as a "tiny demo". Actually, I've
never come around to fully test it... :-/. Now let me go hunt for that
site...
Got it. Thanks for waiting. :-) The name of the program is C-Tree, and
is written by Shaun Flisakowski. It's available from
<ftp://ftp.kagi.com/flisakow/> Look for the files matching the pattern
/^ctree_\d+\.tar\.gz$/ and by this, the subject is brought back to Perl.
Bart.
------------------------------
Date: 22 Apr 1999 09:20:26 -0700
From: Carl Johnson <carlj@peak.org>
Subject: Re: Script to tidy/format a C file
Message-Id: <87k8v4aaph.fsf@cjlinux.localnet>
Myke <myke98@my-dejanews.com> writes:
> Well, I wanted to allow a little more flexibility such as having
> user-definable formatting options. Examples would be whether or not opening
> braces '{' would be on the same line as the control block, or whether they
> started on a new line, and if on a new line, would they be indented or not.
> What's the indent width? Should tabs be for indenting or padded spaces?
> Should comment blocks be indented? Stuff like that.
It sounds like you want the indent program. It should be available from
any GNU archive site.
NAME
indent - changes the appearance of a C program by insert-
ing or deleting whitespace.
INTRODUCTION
The `indent' program can be used to make code easier to
read. It can also convert from one style of writing C to
another.
`indent' understands a substantial amount about the syntax
of C, but it also attempts to cope with incomplete and
misformed syntax.
--
Carl Johnson carlj@peak.org
------------------------------
Date: Thu, 22 Apr 1999 21:49:05 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Small problem, please help (regarding upload)
Message-Id: <7fo56p$jiv$2@oak.prod.itd.earthlink.net>
[ courtesy cc sent by mail if address not munged ]
"Ours" <ours@casema.net> wrote:
>Yes I have ordered CGI/COOKBOOK, but I have to wait for it.
>Please help me on the following matter:
That doesn't stop you from reading the online documentation for CGI.pm.
>I use a webform like this:
>
><FORM ENCTYPE="multipart/form-data"
>ACTION="mydomain/cgi-bin/upload.cgi" METHOD="POST">
><INPUT TYPE="file" Name="filename" Size=35">
><INPUT TYPE="hidden" Name="Number" Value="153698">
><INPUT TYPE="SUBMIT" VALUE="upload">
></FORM>
#!/usr/local/bin/perl -w
use strict;
use CGI qw( :all );
my $form = new CGI;
print header,
start_html,
start_multipart_form,
$form->filefield(-NAME=>'filename',-SIZE=>'35'),
$form->hidden('Number','153698'),
$form->submit('upload','upload'),
end_form,
end_html;
>(the Value of "Number" is a random value generated by another cgi)
Why? It's easier to keep track of what you are doing if you keep it all
in the same place.
>What I would like to do is the following:
>
>Let users upload a file, renaming the file to the random value.
>
>So: reame.txt should be uploaded and stored as for example: 153698.txt
>I also need file-extension control, so they can only upload: MP3 and MP2
>files.
easy enough.
>Can someone please help me? Files should be uploaded to:
>d:/directory/subdirectory on my server
Then tell the script to put them there.
Good luck,
------------------------------
Date: 22 Apr 1999 22:31:19 GMT
From: Bryan Oakley <oakley@channelpoint.com>
Subject: Re: The Future of Tk?
Message-Id: <7fo7vn$irf$12@newsread.f.de.uu.net>
Barry Margolin wrote:
>
> In article <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk>,
> Robin Becker <robin@jessikat.demon.co.uk> wrote:
> >I take this completely differently; least astonishment for me is if
> >program X looks and behaves the same way no matter what keyboard, mouse
> >and screen I'm using. As a 'user' of the program X it shouldn't matter
> >what OS/WM is executing the code. I certainly don't want vi or emacs to
> >be different on the mac why should I treat word or excel differently?
>
> I would be very surprised if Netscape on the Macintosh presented a
> Windows-like user interface, rather than adopting the standard Macintosh
> user interface. Most end users don't switch between platforms much, so
> it's more important that all the programs on their system conform to their
> expectations, than that a particular program work the same across different
> platforms.
I would have to agree with that statement. While there are those who
think retaining the same look and feel across platforms is necessary, I
would wager they are in the distinct minority. That's not to invalidate
their position, but merely to put it in context. _Most_ users of
software want a package to look and feel like the other packages on a
given system. I hate, for example, the artsy (-fartsy) graphic programs
that have some weird UI instead of a more traditional UI.
On the other hand, to some degree this is application-dependent rather
than user-dependent. For example, if I were to have a requirement to
write a air traffic control program that had to run on BeOS, MacOS, NT
and *nix, I would think there would be significant advantages to keeping
it 100% identical across all platforms. So, to some degree it depends on
the application, or the targeted user base.
My point being, there's a need in the world for both models. Only, the
model where applications should adhere to native conventions is (I'm
guessing) far and away the most commonly expected model by most users.
Which is why I think using native windows on Tk is a win -- it meets the
needs of the majority (though definitely not all) of the users in the
world.
--
Bryan Oakley mailto:oakley@channelpoint.com
ChannelPoint, Inc. http://purl.oclc.org/net/oakley
------------------------------
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 5459
**************************************