[8712] in Perl-Users-Digest
Perl-Users Digest, Issue: 2329 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 15 14:07:31 1998
Date: Wed, 15 Apr 98 11:00:41 -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, 15 Apr 1998 Volume: 8 Number: 2329
Today's topics:
avoid double-click on submit button <daryl.nguyen@utoronto.ca>
Re: avoid double-click on submit button <danboo@negia.net>
Re: Bill Gates should be invited to O'Reilly's "Free So <lingnau@tm.informatik.uni-frankfurt.de>
Re: Bill Gates should be invited to O'Reilly's "Free So <ben@hayamasa.demon.co.uk>
C or C++ to perl ? <schmidtj@earth.execpc.com>
Re: C or C++ to perl ? x_bhim@hotmail.com
Re: calculating distance between strings (fortune cooki schwern@starmedia.net
Re: Can someone give me an example of rounding! (susan cassidy)
Re: Can someone give me an example of rounding! <tchrist@mox.perl.com>
CGI Available? lefkogt.xp@usafa.af.mil
Re: correct useage of the if statement <jdf@pobox.com>
Re: Delocalizing $1, $2, etc... <walker@ncbi.nlm.nih.gov>
HELP with a compare sequence skruzich@stc.net
HELP: exec($prog) or die "exec failed"; <peter.szwedyk@eq.gs.com>
Re: Hide or Encrypt perl source code (Dane Jackson)
Re: How to insert a \n each... <danboo@negia.net>
Re: making second option available? <madebeer@igc.apc.org>
Re: Perl and DOS Console on Win32 <keithmur@mindspring.com>
Re: problems with crypt (Matthew Cravit)
Re: recursive fuctions <dean@tbone.biol.sc.edu>
Re: scanning directories <merlyn@stonehenge.com>
Re: stdin/out/err redirection in system() ??? <madebeer@igc.apc.org>
Re: What to use for simple database ? (Andrew M. Langmead)
Re: Which Win32 Perl (Stuart McDow)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 15 Apr 1998 16:00:39 GMT
From: Daryl Nguyen <daryl.nguyen@utoronto.ca>
Subject: avoid double-click on submit button
Message-Id: <3534D9A6.321A50D7@utoronto.ca>
The problem is if one double clicks on the submit button, the perl
script will run twice, if n-click on the submit button, then the script
will run n-times.
I just want to have a script run just ONCE regardless of how many
clicks.
Many thanx
------------------------------
Date: Wed, 15 Apr 1998 12:35:25 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: avoid double-click on submit button
Message-Id: <3534E1CD.A306A9F6@negia.net>
Daryl Nguyen wrote:
> I just want to have a script run just ONCE regardless of how many
> clicks.
no problem:
#!/usr/bin/perl
print "good bye";
unlink $0;
;)
seriously though, i'm not so sure this is a perl question. my guess is
that any potential answer would involve hacks specific to the server
and operating system in use. i would ask in the appropriate groups
for answer pertaining to process detection. one method that comes to
mind is to allow a server process to only allow one connection
at a time. and instead of queueing the client requests, they could be
refused outright. not that it's a great way to do it, but i'm not
sure there are any.
cheers,
--
dan boorstein
------------------------------
Date: 15 Apr 1998 16:07:27 GMT
From: Anselm Lingnau <lingnau@tm.informatik.uni-frankfurt.de>
Subject: Re: Bill Gates should be invited to O'Reilly's "Free Software Summit" (was Re: RMS should be invited to O'Reilly's "Free Software Summit")
Message-Id: <6h2lvv$1k84$1@grapool30.rz.uni-frankfurt.de>
In article <352F42B4.1F047176@hayamasa.demon.co.uk>,
Ben Bullock <ben@hayamasa.demon.co.uk> wrote:
> In some cases the free version might have been just a half-written
> book that the author wanted to get debugged and then turn proprietory,
> such as the Tcl/Tk book by Ousterhout (no, it's not an O'Reilly book)
> instead of an actual free project, but in my opinion that's just
> as bad.
As far as John Ousterhout's book on Tcl/Tk is concerned, there was never
any plan for that to be `free' -- it was supposed to be published by
Addison-Wesley all along. Addison-Wesley graciously consented for the
text to be made available for FTP prior to the publication of the final
book, so that people could comment on the presentation and point out
errors. This arguably resulted in a better book than would have been
possible without the `public beta test'. In fact, John O. asked people
to remove the beta-test versions after the actual book came out -- the
book *is* a lot better than the FTP preview.
Claiming that the book started out `free' but was then suddenly made
`proprietary' after lots of people contributed their comments is grossly
misrepresenting the actual chain of events.
Also, Tcl/Tk comes with excellent reference documentation and lots of
examples.
Anselm
--
Anselm Lingnau ......................... lingnau@tm.informatik.uni-frankfurt.de
Basically, running only DOS on a 386 is a waste of a 386. --- Andrew Bulhak
------------------------------
Date: Wed, 15 Apr 1998 18:17:13 +0100
From: Ben Bullock <ben@hayamasa.demon.co.uk>
Subject: Re: Bill Gates should be invited to O'Reilly's "Free Software Summit" (was Re: RMS should be invited to O'Reilly's "Free Software Summit")
Message-Id: <3534EB98.12CEE88D@hayamasa.demon.co.uk>
Anselm Lingnau wrote:
>
> In article <352F42B4.1F047176@hayamasa.demon.co.uk>,
> Ben Bullock <ben@hayamasa.demon.co.uk> wrote:
>
> > In some cases the free version might have been just a half-written
> > book that the author wanted to get debugged and then turn proprietory,
> > such as the Tcl/Tk book by Ousterhout (no, it's not an O'Reilly book)
> > instead of an actual free project, but in my opinion that's just
> > as bad.
>
> As far as John Ousterhout's book on Tcl/Tk is concerned, there was never
> any plan for that to be `free' -- it was supposed to be published by
> Addison-Wesley all along. Addison-Wesley graciously consented for the
> text to be made available for FTP prior to the publication of the final
> book, so that people could comment on the presentation and point out
> errors. This arguably resulted in a better book than would have been
> possible without the `public beta test'. In fact, John O. asked people
> to remove the beta-test versions after the actual book came out -- the
> book *is* a lot better than the FTP preview.
>
> Claiming that the book started out `free' but was then suddenly made
> `proprietary' after lots of people contributed their comments is grossly
> misrepresenting the actual chain of events.
Yeah, claiming that would be misrepresenting the actual chain of events.
It's a good thing I didn't claim that.
Is there some reason you brought this up?
--
Ben Bullock
------------------------------
Date: Wed, 15 Apr 1998 09:04:32 -0500
From: jeff <schmidtj@earth.execpc.com>
Subject: C or C++ to perl ?
Message-Id: <3534BE70.2628AB90@earth.execpc.com>
It may sound nuts, but we want to translate a c++ program into a perl
script. do any translators, such as a2p or s2p exist for this, or are we
better off writing the script from scratch (learning perl)?
Please respond to jeff@rustam.uwp.edu
Thanks
------------------------------
Date: Wed, 15 Apr 1998 12:14:13 -0500
From: x_bhim@hotmail.com
To: jeff <schmidtj@earth.execpc.com>
Subject: Re: C or C++ to perl ?
Message-Id: <3534EAE5.3166@hotmail.com>
This question has been coming too many times. May be this should be put
in the
FAQ.
Ok here it goes - see the section "PERL compilation!!" below
The best language to use for programming is - "PERL" Write once and run
everywhere!
Perl Language which is very powerful and has all the capabilities of
C++,
bourne shell scripting, awk, sed, csh, Pascal, C, BASIC. Very productive
as it does not require compiling and linking!! Perl is on all platforms
and OSes. Details at -
Main Page: http://reference.perl.com/
Go here and check out the 'ready-to-go' Perl binaries, Perl tutorials,
Perl User interfaces (GUI)...etc ..
PERL Tutorial
-------------
All newbies of Perl are strongly urged to read the Perl tutorial at
the site -
Main Page: http://reference.perl.com/ Go here and see tutorial
title.
PERL User Interfaces (GUI - graphical user interfaces)
-------------------------------------------------------
With PerlQt, PerlTk you write Perl program ONLY ONCE and run the
Perl-GUI programs on Unixes, Windows95/NT and OS/2! Surprise!
PerlQT : See ftp://ftp.redhat.com/pub/contrib/i386 and look
for PerlQt-1.06-1.i386.rpm and Xforms4Perl-0.8.4-1.i386.rpm and
http://www.accessone.com/~jql/perlqt.html
PerlTk : Is included in the distribution
Other Perl GUIkits : See http://reference.perl.com/query.cgi?ui
PERL Database Interfaces
------------------------
Perl has database interface modules for every database i.e Oracle,
Sybase,
Informix, PostgreSQL etc..
See OraPerl, SybPerl, InformixPerl, etc.. at
http://reference.perl.com/query.cgi?database
PERL compilation!!
------------------
When you are done development of project in Perl and your product goes
GA
than you can translate your Perl Project to "C" code using the Perl2C
program
and than compile the resulting C code to generate binary and ship the
binary
to customer. Go here
http://www.perl.com/CPAN-local/modules/by-module/B/
and look for Compiler-a3.tar.gz
Mix and Match C++ with PERL
---------------------------
You can access C++/C from Perl and vice versa.
Go here http://www.perl.com/CPAN-local/CPAN.html and see topic
09 Interfaces_to_Other_Languages: C, C++, Prolog, Tcl
You can still write "bottleneck' modules in "C++" and use it inside
Perl program! Most projects are generally 95% perl + 5% "C++".
Easy Migration to PERL from Shell, awk and sed scripts
-------------------------------------------------------
There are programs to migrate your Bourne shell scripts, awk scripts and
sed scripts to perl. They are sh2perl which is at -
http://www.perl.com/CPAN/authors/id/MERLYN/sh2perl-0.02.tar.gz
awk to perl a2p and sed to perl s2p is included with perl distribution.
If have Perl than you do NOT need awk, sed, bourne shell, ksh, csh
scripts
and C, C++, Pascal, BASIC, COBOL !
PERL Frequently Asked Questions
--------------------------------
Also see FAQs and other URLs at -
http://www.yahoo.com/Computers_and_Internet/Programming_Languages/Perl/
jeff wrote:
>
> It may sound nuts, but we want to translate a c++ program into a perl
> script. do any translators, such as a2p or s2p exist for this, or are we
> better off writing the script from scratch (learning perl)?
> Please respond to jeff@rustam.uwp.edu
> Thanks
------------------------------
Date: Wed, 15 Apr 1998 11:46:59 -0600
From: schwern@starmedia.net
To: sitaram@diac.com
Subject: Re: calculating distance between strings (fortune cookies)
Message-Id: <6h2oa3$2k9$1@nnrp1.dejanews.com>
>>> I'm looking for a program/script/whatever that can calculate the
>>> distance between two text-strings. By distance I mean that I want
>>> to find strings that human beings can identify as "the same", but a
>>> computer would not directly consider equal in the sense: ($StrX eq
>>> $StrY)
>Sorry for the very vague pointers to reference articels. Dejanews
>popped Text::Metaphone for this kind of tranform up.
Your best bet is probably to start working with Text::Metaphone and
String::Approx as your core. T::M produces a much more accurate approximation
of a word's pronunciation than Soundex (this is my totally unbiased opinion...
being the T::M module author has nothing to do with it, really :)
I use them as a simple Bad Speller's Dictionary (english only and rather
sluggish)...
http://www.rt1.net/~schwern/InTheWorks/perl/bspell
use Text::Metaphone;
use String::Approx qw(amatch);
open(WORDS, '/usr/dict/words') || die $!;
$word = Metaphone(shift);
while(<WORDS>) {
print if String::Approx::amatch($word, \@ARGV, Metaphone($_));
}
print "\n";
Feed that a word and an optional list of String::Approx mods and you'll get
back a list of words that sound something like your word. Not perfect, but
its sometimes smarter than ispell.
I don't know how well something of this style will scale up to entire
sentences.
Also, look into how ispell does its spell checking. It may prove useful.
--
Michael G Schwern Applications Engineer
(212)548-9643 Starmedia Networks Unix Bigot
schwern@starmedia.net Raving Perl Advocate
"The doctrine of human equality reposes on this: that there is no man really
clever who has not found that he is stupid." G. K. Chesterton
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 15 Apr 1998 06:01:37 -0700
From: susanc@news.SanDiegoCA.ncr.COM (susan cassidy)
Subject: Re: Can someone give me an example of rounding!
Message-Id: <6h2b3h$qth@ssd3450.SanDiegoCA.NCR.COM>
In article <6gubjs$cil$1@comdyn.comdyn.com.au>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>In article <Pine.BSI.3.96.980410100551.16994A-100000@pentagon.io.com>,
> Chocolate <poohba@io.com> writes:
>> I don't nor will I have access to the web for about a week or two so I
>> would really appreciate it if someone would tell me how to round to 2
>
>You don't need to have access to the web to read the perl
>documentation. It should come with your installation of perl.
>
>perldoc perlfaq
>perldoc perlfaq4
>/Does perl have a round function
>perldoc sprintf
>
>> decimal point. I don't know how much different it will be but I am not
>> too familiar with perl5.
>
>different from what?
>
>[Snip of very long signature. You should consider trimming it a bit]
>
>Martien
>--
>Martien Verbruggen |
>Webmaster www.tradingpost.com.au | Advertising: The science of arresting
>Commercial Dynamics Pty. Ltd. | the human intelligence long enough to
>NSW, Australia | get money from it.
Just a caveat, I have seen many postings in this news group recommending
that people use sprintf/printf to round numbers. Sprintf/printf will not,
by themselves round anything. They will truncate, which is entirely
different. Normally you have to add half of the rightmost decimal
position to round to one less position. E.g. if you have a number like
12.16, and you want to round to 12.2, you have to add .005 before
truncating to 1 position after the decimal.
Hope this helps.
--
Susan Cassidy
Remove xxx in replyto address when replying.
------------------------------
Date: 15 Apr 1998 16:59:16 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Can someone give me an example of rounding!
Message-Id: <6h2p14$9es$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
Using a munged address now committed to my despam page, in
comp.lang.perl.misc susan.cassidy@sandiegoca.ncr.com writes:
:Just a caveat, I have seen many postings in this news group recommending
:that people use sprintf/printf to round numbers. Sprintf/printf will not,
:by themselves round anything. They will truncate, which is entirely
:different.
I don't know why people think printf truncates; it certainly rounds.
You could have found this out by reading the documentation, or by using
a trivial test:
% perl -e 'printf "%4.2f\n", 2.5555'
2.56
--tom
Please don't send spam to susan.cassidy@sandiegoca.ncr.com
--
Tom Christiansen tchrist@jhereg.perl.com
``I do quarrel with logic that says, `Stupid people are associated with X,
therefore X is stupid.' Stupid people are associated with everything.''
--Larry Wall in <1992Dec31.203724.26018@netlabs.com>
------------------------------
Date: Wed, 15 Apr 1998 12:18:00 -0600
From: lefkogt.xp@usafa.af.mil
Subject: CGI Available?
Message-Id: <6h2q48$5aa$1@nnrp1.dejanews.com>
Is there an "industrial-strengthed" PERL CGI for running surveys on the net
that results get appended to a ASCII datafile? It MUST be able to be used on
surveys that span multiple webpages, and "remembers" page 1 data should I
decide on page 4 that I need to correct a response.
Gary
Institutional Research
US Air Force Academy
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 15 Apr 1998 12:18:32 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: correct useage of the if statement
Message-Id: <wwcrc8bb.fsf@mailhost.panix.com>
syarbrou@ais.net (Steve) writes:
> The following comes up as true when $entry[22] is equal to 6NA:
>
> $entry[22] eq '6'
> $entry[22] eq "6"
I daresay that's impossible. Please post a brief but complete code
example that demonstrates this behavior. Why do you think that
$entry[22] contains '6NA' at that point in the code? Are you stepping
through your script in the debugger? Is there a print statement just
before the comparison?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Wed, 15 Apr 1998 11:47:22 -0400
From: Roland Walker <walker@ncbi.nlm.nih.gov>
To: "yary h." <fecund@fatnet.net>
Subject: Re: Delocalizing $1, $2, etc...
Message-Id: <3534D68A.E97C5557@ncbi.nlm.nih.gov>
yary h. wrote:
> I think it would be cool if the caller could then use $1, $2 etc.
> But they're always local to the current block. Is there a way to
> un-localize them
You can do this, but it is more trouble than it is worth.
R
do_match();
print $1."\n";
print $2."\n";
sub do_match {
'The quick brown fox jumped over the lazy gods' =~ /(fox).*(over)/;
$global1=$1;
$global2=$2;
*1=*global1;
*2=*global2;
}
------------------------------
Date: Wed, 15 Apr 1998 11:04:14 -0600
From: skruzich@stc.net
Subject: HELP with a compare sequence
Message-Id: <6h2lpt$uum$1@nnrp1.dejanews.com>
Hi,
I am attempting to take a couple values compare them to make the choice
to do a certain task.
I have a package called Reel backup, that the company is adament about using.
It is nothing more than a set of multiple programs to execute tape
operations. It does however have a limited, cheesy tk interface that
allows you to do tasks manually. I personally however do not wish to be
here when operations start the backups at 03:00 am and cannot expect the
operations to actually startup the backup. So i decided to attempt to
write a script to do this.
I will attempt to make it clear as to what i wish to do
1. I have 7 tapes. labeld 000001 - 000007.
2. I am doing a exec(date command to get the abrev day ex Mon Tue Wed ....
3. I need to associate the day of week with the label of tape. (No, i
can't label the tapes to the abrev day of week.
4. After verifying that the tape in the drive is the correct tape,
continuing on with the backup proceedure.
5. If this is not the correct tape, or no tpe is inserted, broadcast a
message to athe console, and or another monitoring location to insert the
correct tape.
6. Sleep for a period of time, then attempt to verify the tape again til
the tape is correct.
7. Tapes must be inserted sequentially, since each one has a tag on it,
as well as a expiration tag.
8. Tapes will cycle in 6 days returning them to a scratch status.
9. I am testing for labels, since each label coincides with a day of the
week.
10. With this script all one needs to do is insert tape. :> I know
wishful thinking
grin
Problems encounted.
Remember I am not very experienced in programming in general, and Perl is
the only language that i know other than LPC and Assembler. So please be
patient with me ;>
1. The system( statement below, loops, without getting to the subroutines).
2. I have tried while(<>) and foreach loops with no success.
3. My brain is fried from trying to think this one out.
What i have is the following
# The following section is to offer the choice of Automatic or manual oper
print "Do you wish to be Prompted for each instruction? ";
$yn = <STDIN>;
chop($yn);
if ($yn =~ /^Y/i)
{
print "Starting up in Interactive Mode.\n";
while (! &interactive)
{
}
}else{
print "starting up in Automatic mode. \n";
while (! &automatic)
{
}
}
close(IN);
close(OUT);
# The following are various things that i set.
exec("date +'%a'` > today");
open(TODAY, "today") || die "Cannot open today file.\n";
$day = <TODAY>;
$tape1 = "000001";
$tape2 = "000002";
$tape3 = "000003";
$tape4 = "000004";
$tape5 = "000005";
$tape6 = "000006";
$tape7 = "000007";
sub automatic
{
open(REGIONS , "region") || die "Cannot open region filename.\n";
system("rbtapevol adn=dlt1 > currenttape");
open(TAPES, "currenttape") || die "Cannot open current tapefile.\n";
@region_in = <REGIONS>;
@tapelist_in = <TAPES>;
foreach $tape(@tapelist_in)
{
if ($day =~ "Mon")
{
if ($tape =~ "$tape1")
{
&Monday_tape
}
}elsif ($day =~ "Tue")
{
if ($tape =~ "$tape2")
{
&Tuesday_tape
}
}elsif ($day =~ "Wed")
{
if ($tape =~ "$tape2")
{
&Wedsday_tape
}
}else{
&Error_1
}
}
last;
}
# Note I am going to insert the commands i need done in the subroutines.
# right now i am using print statements to follow where the program goes.
sub Monday_tape
{
print "Insert Monday tape labeled 000001\n";
}
sub Tuesday_tape
{
print "Insert Tuesday tape labeled 000002\n";
}
sub Wedsday_tape
{
print "Insert Wedsday tape labeled 000003\n";
}
sub Error_1
{
print "Incorrect tape inserted or no tape is present!\n";
}
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 15 Apr 1998 12:55:02 -0400
From: PETER SZWEDYK <peter.szwedyk@eq.gs.com>
Subject: HELP: exec($prog) or die "exec failed";
Message-Id: <3534E665.36B5A997@eq.gs.com>
When I waitpid for exec to finish, I can check $? for child error, BUT
WHAT IF I DON'T waitpid? In this case, $? is always 0, even if exec
failed.
HOW CAN I CATCH THE die "exec failed" back in the parent program? I
know that I could redirect STDERR in child to write to a file and then
back in parent read in that file and parse for 'exec failed'. IS THERE
AN EASIER WAY??? Can I redirect the die "exec failed" streight to a
string var in the parent process?
Here is my script. Thanks in advance!
$exec_str = "load_data.pl";
$fg_bg_indic = 'B';
select (STDERR); $| = 1;
select (STDOUT); $| = 1;
FORK: {
if ($pid = fork)
{
if($fg_bg_indic eq 'B')
{
print "not waiting...\n";
}
else
{
print "waiting...\n";
waitpid($pid,0);
}
}
elsif (defined $pid)
{
print "exec...\n";
exec ($exec_str) or die "exec failed: $!";
exit;
}
elsif ($! =~ /No more process/)
{
sleep 5;
redo FORK;
}
else
{
die "can't fork: $!\n";
}
}
print "OS ERRr: $!, CHILD ERR: $?\n"; #if child sent to background,
------------------------------
Date: 15 Apr 1998 16:30:33 GMT
From: dpj@ddt.occ.uc.edu (Dane Jackson)
Subject: Re: Hide or Encrypt perl source code
Message-Id: <6h2nb9$qi7$1@malgudi.oar.net>
: >3) Encrypt the string in the source. This will give the level of
: >security that compiling does. Use one of the filter modules, or just
: >xor some strings into yours, and do that in your script - then you
: >won't "expose" the information directly. The user willhave to do a
: >little more work then just using strings or such.
Using crypt would probably help, first encrypt your
password 'foobar' = foa3VCPbMb8XQ
$encrypteduserstring = crypt $userstring,$somesalt;
if ($passwordstring eq $encrypteduserstring){
..do something..
}
else{
..else tell them they gave an invalid password..
}
crypt is standard perl, so you shouldn't ahve any problems using
it or finding references on it.
--
Dane Jackson - zuvembi@mindless.com
Murphy's Laws of Computing #7
"He who laughs last probably made a back-up"
------------------------------
Date: Wed, 15 Apr 1998 12:20:38 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: How to insert a \n each...
Message-Id: <3534DE56.D8AC5BA6@negia.net>
Bart Lateur wrote:
>
> LE CORRE wrote:
>
> >I want to insert a \n each 10 char to display :
> >03131721223033364649
> >08111622242930374041
> >
> >I tried $line=~ s/.{10}/\n/g; but it doesn't work.
>
> Keep what you match:
>
> $line =~ s(.{10})/$1\n/g;
^
insert '/'
--
dan boorstein
------------------------------
Date: Sun, 12 Apr 1998 17:25:25 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: making second option available?
Message-Id: <APC&1'0'50775d8e'659@igc.apc.org>
Look in the perlfunc manpage and search for ' exec LIST'
You'll find this:
exec LIST
The exec() function executes a system command AND
NEVER RETURNS. Use the system() function if you
want it to return.
If there is more than one argument in LIST, or if
LIST is an array with more than one value, calls
execvp(3) with the arguments in LIST. If there is
only one scalar argument, the argument is checked
for shell metacharacters. If there are any, the
entire argument is passed to /bin/sh -c for parsing.
If there are none, the argument is split into words
and passed directly to execvp(), which is more
efficient. Note: exec() and system() do not flush
your output buffer, so you may need to set $| to
avoid lost output. Examples:
exec '/bin/echo', 'Your arguments are: ', @ARGV;
exec "sort $outfile | uniq";
You want to do something like:
exec ($cmd, $option1, $option2)
-Michael de Beer
------------------------------
Date: Wed, 15 Apr 1998 11:01:37 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Perl and DOS Console on Win32
Message-Id: <3534D9E1.18D32380@mindspring.com>
Michael Kairys wrote:
>
> Bill Hess wrote in message ...
> >I am running Perl 5.004_04 on WinNT/Win95 and I need to run a Perl Program
> >with no DOS Console window popping up - how can I do this???
>
> Cross-posted from comp.lang.perl.tk:
>
> From: Michael Kairys <kairys@mi.sl.com>
> Subject: Using Win32::Process::Create to avoid console window
> Date: Monday, April 13, 1998 11:26 AM
>
> Someone posted this as a suggestion and I was intgrigued, because I would
> like to find a way to run Perl-Tk scripts without the "extra" window. So I
> coded up a "startperl" script that called Win32::Process::Create as
> described. I found that the scripts I ran with it were failing, and after
> some experimentation I found that, in the script running in the created
> process,
>
> 1. Filename globbing, whether via "<>" or "glob()", fails. "glob(anything)"
> returns nothing.
> 2. Backticks fail to do anything. system() works, but pops up a console
> window for an instant.
>
> The first I could work around but the second was a killer. I don't suppose
> anyone has a quick fix for either problem at the tips of their fingers? (:-)
>
That's kind of interesting. I've been creating processes running Perl
from a Delphi program. There's several things I need to do to get the
results I want, which you can't manipulate in calling
Win32::Process::Create; so I don't know how it sets them. One thing you
need to do is make a STARTUPINFO structure with the standard handles set
for the STDOUT, STDIN, STDERR you desire. Another important one is to
have flags in there that say whether to show a window or not. The one
that I would *guess* is biting you is that you need to pass on an
environment block to the created process.
I can manipulate these things very finely by calling the API directly
from Delphi, and have it jumping through the hoops I want.
Is there any sort of generalized routine or method for calling DLLs from
Perl directly? Then you wouldn't have to rely on stuff like
Win32::Process::Create.
------------------------------
Date: 15 Apr 1998 09:22:26 -0700
From: mcravit+usenet@mcravit.vip.best.com (Matthew Cravit)
Subject: Re: problems with crypt
Message-Id: <6h2ms2$n3v$1@shell3.ba.best.com>
In article <3534B411.B227AB63@houston.Geco-Prakla.slb.com>,
Dave Barnett <barnett@houston.Geco-Prakla.slb.com> wrote:
>
>perldoc -f crypt states that crypt behaves just like crypt(3), but I
>don't see anything in man -s3c crypt that tells me that the cutoff is 8
>significant characters.
>From the man page for crypt on my system (Solaris 2.6):
The key argument points to a string to be encoded (for exam-
ple, the user's password.) Only the first eight characters
are used; the rest are ignored.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@net.com (work) | time you make it.
------------------------------
Date: 15 Apr 1998 11:36:04 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: recursive fuctions
Message-Id: <8790p72j2z.fsf@tbone.biol.sc.edu>
Tom Phoenix <rootbeer@teleport.com> writes:
> To be sure, you should use defined() there, since the file or directory
> name could be '0'. A future version of Perl will remove that potential
> bug.
No kidding. So you've "found" that one, too... Don't tell me, let me
guess: you were crawling the directory tree under terminfo and hit the
directory that contains all the terminal descriptions beginning with
"0". Thud.
But note that, as I recall, I ran into that using File::Find. I sent
off a bug fix/report to its author (Graham Barr?), so that should be
taken care of in more recent versions -- this was a few months ago.
By the way, Tom - thanks for all your time and effort in clpm. Be
careful not to burn yourself out!
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)
------------------------------
Date: Wed, 15 Apr 1998 16:13:50 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: pidde@uni-koblenz.de
Subject: Re: scanning directories
Message-Id: <8chg3vm5ba.fsf@gadget.cscaper.com>
>>>>> "Andreas" == Andreas Pidde <pidde@uni-koblenz.de> writes:
Andreas> Hi, you can use the readdir function and a traverse the
Andreas> directory tree, try:
[faulty handcrafted directory recursion code snipped]
Please don't rewrite File::Find::find. It's shipped with the standard
distribution for many reasons. One of which is that it doesn't start
going off into deep space when it sees a symlink to a directory, as
yours would have.
Thanks for posting the code, but the proper answer is "use File::Find".
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 138 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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: Sun, 12 Apr 1998 17:38:37 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: stdin/out/err redirection in system() ???
Message-Id: <APC&1'0'50775d8f'9a5@igc.apc.org>
Also, read the perlfunc manpage, and look for SELECT.
You can redirect STDOUT and STDERR to files on a global or local basis.
-Michael de Beer
madebeer@n_o_spam.igc.org
------------------------------
Date: Wed, 15 Apr 1998 16:19:51 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: What to use for simple database ?
Message-Id: <ErGqp3.CJF@world.std.com>
Dan Baker <dtbaker_@flash.net> writes:
>what would the considerations be for deciding whether you wanted to use
>regular lists or assoc arrays? i.e. is there some aproximate number of
>lines of data where lists may be better than hashes, or should you
>always use hashes for this sort of thing?
Use hashes if you want to get the piece of data associated with a
string (referred to as the key of the hash.)
Use an array if you want to get the piece of data associated with a
certain number out of a set of consecutive numbers. (refered to as the
index to the array)
Use an array if the order of the data matters, that is, if you need
the first, seventh, or last piece of data.
Since you need to find the piece of data associated with a name, then
the hash is the data structure of choice. If you needed to get a piece
of data by record number, (the first record, the last record, etc.)
then an array would be appropriate
>How about using the MDB fuctions to an assoc array written to disk? when
>does that become reasonably effiecient? (and is it available on win32?)
If you want to associate a string with a piece of data, and you want
this data to persist after the program quits, and the entire data set
is too large to fit in memory all at once (or it would take too much
time to read all of the data), and you want to access the data quickly
(instead of reading through the file to find the item you want), a DBM
file is a useful way of storing and retrieving the data.
--
Andrew Langmead
------------------------------
Date: 15 Apr 1998 16:09:46 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Which Win32 Perl
Message-Id: <6h2m4a$7n4$1@ns1.arlut.utexas.edu>
rob@frii.com (Rob Greenbank) writes:
>
> I've read the description of the differences between "Active State"
> and "Gurusamy Sarathy's" versions. I like the sounds of GS's, but
> before I blow away my "Active State" version I'd like to know if
> anyones had any problems with GS's. Also, anyone had problems
> switching between the versions?
The "Gurusamy Sarathy's" versions. I like the sounds of GS's, but
> before I blow away my "Active State" version I'd like to know if
> anyones had any problems with GS's. Also, anyone had problems
> switching between the versions?
The "Gurusamy Sarathy" version is known as the "core" version. It uses
the same code base as the Un*x versions. I'm using the core 5.004_2
version for win32, and I've had no problems with it. It comes bundled
with many nifty packages, most importantly (to me), Tk. I've developed
a few very GUI intensive applications that run on serveral versions of
Un*x *and* on mswin32 machines. Without changing any code. It makes
for very, very portable applications. I've never had any problems
(execpt those that come with running under a broken operating system)
with the core mswin32 release.
I don't know much about the ActiveState port, but it does seem to
diverge somewhat from the core distribution. Someone more
knowledgeable should make that comparision. I suspect it would be
easier to add modules with the core version, but I haven't had to mess
with that yet.
Hope this is helpful.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"It is obvious that about 750,000 people ago, Austin was a wonderful City."
------------------------------
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 2329
**************************************