[17038] in Perl-Users-Digest
Perl-Users Digest, Issue: 4450 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 27 18:20:37 2000
Date: Wed, 27 Sep 2000 15:20:24 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <970093224-v9-i4450@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 27 Sep 2000 Volume: 9 Number: 4450
Today's topics:
Re: retrieve the date and size of a file running <westxga@my-deja.com>
Running other processes and waiting <kyle@iol.ie>
Re: Shortest code for Fibonacci? <quantum_mechanic@my-deja.com>
Substituting $variable strings in a file tebrusca@my-deja.com
Re: Substituting $variable strings in a file <dsimonis@fiderus.com>
Re: system("cd /var") command <randy_734@my-deja.com>
Re: unexpected changes from 5.005_03 to 5.6.0 <honeyman@decipher.com>
Re: unexpected changes from 5.005_03 to 5.6.0 <honeyman@decipher.com>
Untar Works at Prohosting... Thanks (BUCK NAKED1)
Re: What does this do?! rathmore@tierceron.com
Re: Win32::Process::Create Help! <amonotod@netscape.net>
Re: Windows 98 / Active Perl / CGI (Tim Hammerquist)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 27 Sep 2000 18:02:51 GMT
From: Glenn West <westxga@my-deja.com>
Subject: Re: retrieve the date and size of a file running
Message-Id: <8qtco4$a2p$1@nnrp1.deja.com>
In article <8qt6lf$4ao$1@nnrp1.deja.com>,
pim53@my-deja.com wrote:
> Hi,
> I want to retrieve the date of last modification
> of a file and its size.
> So I used -s and -M to get that.
> But somehow, for a file that is running at the
> same time this test return that the file doesn't
> exist even it does.
> SO I used th `ls`command but I cannot get a full
> date like 09/27/2000 17:45:56
> How can I do?
> Thanks...
perldoc -f stat
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 27 Sep 2000 18:20:31 GMT
From: Kyle Parfrey <kyle@iol.ie>
Subject: Running other processes and waiting
Message-Id: <39D239F3.D2E338@iol.ie>
Hi all.
I have been trying to write a perl program that simply calls a plotting
program called gnuplot, makes it do something then exits (it is as
preparation for a bigger project). I was using a filehandle to write to
gnuplot (command line interface) but the graph that it creates flashes
on the screen and the perl program exits. Is there a simple way that I
can have the graph onscreen awaiting an order from the keyboard to get
rid of it? I have heard about an expect function or system but can't
find anything about it in "programming perl".
Thanks,
Kyle
------------------------------
Date: Wed, 27 Sep 2000 19:16:56 GMT
From: Quantum Mechanic <quantum_mechanic@my-deja.com>
Subject: Re: Shortest code for Fibonacci?
Message-Id: <8qth2u$ea4$1@nnrp1.deja.com>
In article <39c1c5ee.5f9e$1f8@news.op.net>,
mjd@plover.com (Mark-Jason Dominus) wrote:
> If you really need it to be efficient, and you expect n to be large,
> there is an O(log n) algorithm:
>
> sub fib {
> my ($a) = mm($_[0]);
> $a;
> }
>
> sub mm {
> my ($n) = @_;
> return (1, 0, 0, 1) if $n == 0;
> return (1, 1, 1, 0) if $n == 1;
> if ($n % 2) { # odd n
> my ($a, $b, $c, $d) = mm($n-1);
> ($a+$b, $a, $c+$d, $d);
> } else { # even n
> my ($a, $b, $c, $d) = mm($n>>1);
> my ($ad, $bc) = ($a+$d, $b*$c);
> ($a*$a+$bc, $b*$ad, $c*$ad, $d*$d+$bc);
> }
> }
>
<snip>
> but it's past 2:30 AM here and I can't remember it offhand.
>
>
Your efficient algorithm is very quick indeed, but it fails at F(12),
giving 139 instead of 144. There is probably a typo in there somewhere,
can you spot it?
-QM
--
Quantum Mechanics: The dreams stuff is made of.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 27 Sep 2000 19:51:21 GMT
From: tebrusca@my-deja.com
Subject: Substituting $variable strings in a file
Message-Id: <8qtj3m$g23$1@nnrp1.deja.com>
I want to embed variable names in a file
then read the file and have the variables
interpreted. Below is the shell of the
code, I've tried escapes, eval, and read
all docs I could think of ... I DON'T
want to do it with S/UBSTI/TUITION or with
< <HERE. Basically I'm thinking the program
is compiled and there's no way to get it
to interpret the $word in the file?
#!/usr/local/bin/perl -w
use strict;
use diagnostics;
my $word = "stinky";
## I actually want to read from a file
my $string = <DATA> ;
## I want to interpret variables stored in file
print $string;
__END__
this is my $word program
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 27 Sep 2000 16:08:49 -0400
From: Drew Simonis <dsimonis@fiderus.com>
Subject: Re: Substituting $variable strings in a file
Message-Id: <39D253D1.8A5F029@fiderus.com>
tebrusca@my-deja.com wrote:
>
> I want to embed variable names in a file
> then read the file and have the variables
> interpreted.
This is a FAQ. Have you looked there?
------------------------------
Date: Wed, 27 Sep 2000 18:08:45 GMT
From: Randy <randy_734@my-deja.com>
Subject: Re: system("cd /var") command
Message-Id: <39d236a8.20411953@207.126.101.100>
aravindh@technologist.com wrote:
>Sorry about my posting style.
>
>#!/usr/bin/perl
>use strict;
>use Cwd;
>print cwd() ,"\n";
>chdir ("/var");
>print cwd() ,"\n";
>
>i tried the code. but when i come out of the program i am back in the
>location where i started. i need to be in /var when the program exits.
>how can do it? thanks for all the help.
>
Easy. Be in /var when the program starts. When you run the program a
new shell is spawned. Changes you make to that environment have no
effect on the parent shell. When your program ends the process and
all of its environment go away with it.
------------------------------
Date: Wed, 27 Sep 2000 14:26:22 -0400
From: Ryan Honeyman <honeyman@decipher.com>
Subject: Re: unexpected changes from 5.005_03 to 5.6.0
Message-Id: <39D23BCD.E1B9A6F0@decipher.com>
*** post for free via your newsreader at post.newsfeeds.com ***
> Works fine for me on both 5.005_03 and 5.6.0.
> This is perl, version 5.005_03 built for i386-linux
> This is perl, v5.6.0 built for i686-linux-thread-multi
I just tried to recompile v5.6.0 in hopes that maybe something
went wrong when I built it before. I'm getting the same results
with the code example on various machines.
o First on a sparc20, 5.005 works, 5.6.0 still fails.
SunOS 5.6 sun4m sparc SUNW,SPARCstation-20
This is perl, v5.6.0 built for sun4-solaris
This is perl, version 5.005_03 built for sun4-solaris
o Then on an E450, 5.005 runs the code correctly, 5.6.0 doesn't
SunOS 5.6 sun4u sparc SUNW,Ultra-4
This is perl, v5.6.0 built for sun4-solaris
This is perl, version 5.005_03 built for sun4-solaris
o Then I recompiled perl on a Netra t1, 5.6.0 still didn't produce
the correct results.
SunOS 5.7 sun4u sparc SUNW,UltraSPARC-IIi-cEngine
This is perl, v5.6.0 built for sun4-solaris
o Then I tried on the linux platform, too. No luck here.
Linux 2.2.14 #7 Sat Sep 16 16:47:16 EDT 2000 i586 unknown
This is perl, version 5.005_03 built for i386-linux
This is perl, v5.6.0 built for i586-linux
So what could be different that allows your installation to
run as it should, and all the builds I just tried to fail?
+=================================+
| Ryan Honeyman, Programmer /
| Decipher, Web Group /
| http://www.decipher.com /
+-----------------------------+
| phone> 757.664.1126 /
| pager> 757.629.1567 /
+==========================+
**** Post for FREE via your newsreader at post.newsfeeds.com ****
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*** Newsfeeds.com - The #1 Usenet Newsgroup Service on The Planet! ***
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
http://www.newsfeeds.com | http://www.newsfeeds.com
|
* Anonymous posting server! | * Totally Uncensored!
* SUPER Servers! | * Over 80,000 Newsgroups!
* BINARIES ONLY Servers! | * 16 seperate Newsgroup Servers!
* SPAM FILTERED Server! | * Instant access!
* ADULT ONLY Server! | * Multiple OC 3's and OC 12's!
* MP3 ONLY Server! | * 99% Article Completion!
* MULTIMEDIA ONLY Server! | * Months of Retention!
* 7 UNCENSORED Newsgroup Servers | * Lightning FAST downloads!
|
http://www.newsfeeds.com | http://www.newsfeeds.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
**** Point your newsreader to post.newsfeeds.com ****
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: Wed, 27 Sep 2000 16:34:23 -0400
From: Ryan Honeyman <honeyman@decipher.com>
Subject: Re: unexpected changes from 5.005_03 to 5.6.0
Message-Id: <39D259CF.965826D5@decipher.com>
*** post for free via your newsreader at post.newsfeeds.com ***
Regarding the code snip at the end of the post:
I've found ways to make things work correctly. Putting quotes
around the variable in the int() function fixes it. Assembling
the variable in a particular way, with quotes in particular
spots. If I turn off strict and stop using my, it all works as
well. But that's not compatibility. This code runs perfectly
on my old 5.002, 5.004, 5.005 perl. It does not produce the
correct numbers on 5.6.0; on five different machines, and three
different OS architectures. Perl has always 'worked' for me.
And now it's still giving me a little grief when working with
hybrid string/integers and apparently some strange variable
assignment issue in 5.6.0. Can anyone reproduce this? If so,
any idea why this is happening?
+=================================+
| Ryan Honeyman, Programmer /
| Decipher, Web Group /
| http://www.decipher.com /
+-----------------------------+
| phone> 757.664.1126 /
| pager> 757.629.1567 /
+==========================+
----------
my $this = 2;
my $that = 0;
print "this starts at $this, that starts at $that\n";
if ($this <= 10) { $that = "1$this"; }
if ($this <= 10) { $this = "1$this"; }
print "this = $this, that = $that, both should be 12\n\n";
print "multiply ($this * 2): ".($this * 2)." (should be 24)\n";
print "multiply ($that * 2): ".($that * 2)." (should be 24)\n";
print "\n";
print int($that)." <-- that should be 12\n";
print int($this)." <-- this should be 12\n";
**** Post for FREE via your newsreader at post.newsfeeds.com ****
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*** Newsfeeds.com - The #1 Usenet Newsgroup Service on The Planet! ***
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
http://www.newsfeeds.com | http://www.newsfeeds.com
|
* Anonymous posting server! | * Totally Uncensored!
* SUPER Servers! | * Over 80,000 Newsgroups!
* BINARIES ONLY Servers! | * 16 seperate Newsgroup Servers!
* SPAM FILTERED Server! | * Instant access!
* ADULT ONLY Server! | * Multiple OC 3's and OC 12's!
* MP3 ONLY Server! | * 99% Article Completion!
* MULTIMEDIA ONLY Server! | * Months of Retention!
* 7 UNCENSORED Newsgroup Servers | * Lightning FAST downloads!
|
http://www.newsfeeds.com | http://www.newsfeeds.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
**** Point your newsreader to post.newsfeeds.com ****
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: Wed, 27 Sep 2000 16:23:44 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Untar Works at Prohosting... Thanks
Message-Id: <14112-39D26560-17@storefull-243.iap.bryant.webtv.net>
Thanks Bart L. for directing me back to the Archive::Tar module. For
some reason, Compress:Zlib unzipping examples from the perldocs wouldn't
work... though the module is installed on my webserver.
I found out that the unix commands, such as "gunzip," didn't work to
unzip a tar file because my webserver has them turned off for their free
customers. I imagine this is true for other free servers as well.
(Duh... wish I'd thought of that!)
Anway, the code is down and dirty, and I'm not even sure if the
content-type is correct, but here's the code that finally worked.
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
use Archive::Tar;
$tar = Archive::Tar->new();
$tar->extract_archive("xxx.tar.gz",1)
Again many, many thanks to all,
DENNIS
------------------------------
Date: Wed, 27 Sep 2000 18:43:15 GMT
From: rathmore@tierceron.com
Subject: Re: What does this do?!
Message-Id: <8qtf40$cau$1@nnrp1.deja.com>
> Good book, isn't it?
Most excellent! Not finished just yet.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 27 Sep 2000 19:11:21 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Win32::Process::Create Help!
Message-Id: <8qtgog$dt9$1@nnrp1.deja.com>
In article <8qsr1j$phk$1@nnrp1.deja.com>,
dj_morri@my-deja.com wrote:
> Hi all,
>
> I'm trying to spawn multiple perl processes from my main perl script.
> fork() wont work for me on NT and Perl 5.005 (5.6 is not an option).
Check out the examples from Dave Roth's Perl book(and maybe even buy the
book, I recommend it highly):
http://www.roth.net/books/extensions/examples.zip
The book has great documentation, examples, and insight for Perl on
Win32.
HTH,
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 27 Sep 2000 20:08:17 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Windows 98 / Active Perl / CGI
Message-Id: <slrn8t4ln8.1hv.tim@degree.ath.cx>
oi03_2000@my-deja.com <oi03_2000@my-deja.com> wrote:
> Tim, thanks for your direction. It was really helpful. I was in a hurry
> to get the script working, so I did not read my book thoroughly. Yes, I
> missed the "Content type" in my script, secondly there was another minor
> syntactical error in the script (html part) because of which the script
> did not work.
Glad I could help. =)
> But the script never ran on Personal web server though. So I
> downloaded/installed Apache server on win 98 and every thing is working
> fine now. Excepting that the line "content type" shows up on my output
> page on the web browser. I'm sure that's not supposed to happen, still
> need to figure that out.
If "content type" (or hopefully "Content-type: text/html") shows up in
the browser, then the header was probably already sent. This could come
from anywhere, but most likely comes from a call to CGI::header(). For
instance:
# ex 1
use CGI; # keeps namespaces cleaner
print CGI::header();
# ex 2
use CGI qw(:standard); # clutters namespaces, but trade-off
print header(); # for convenience
# ex 3
use CGI;
my $q = new CGI; # object-oriented CGI interface;
print $q->header(); # tidier namespaces; less ambiguity
If you use any of those statements, you can probably remove yours.
Simply make sure that however you call header() it must be the first
output your script makes to STDOUT.
> I'm very excited about apache and perl and the myriad things you can do
> with perl. Thanks again for the help.
I was pleased with Win98/Apache as well, though there were still the
standard Win32 stability problems. Apache has not been stable enough
for production/public level serving on Win32 yet, but it's a great tool
nevertheless.
To keep in mind: if you get into Apache/mod_perl, most recent versions
of CGI.pm are designed to work seemlessly with it.
Warning: some people (on this list) disapprove of CGI.pm. It has been
described by its own author as "monolithic" and does tend to
load/compile relatively slowly. However, CGI.pm provides many HTML
shortcuts that can make life much easier. By all means, use it. If
time-to-load is important, investigate mod_perl for Apache; it stores
precompiled modules in memory so it only has to parse/compile them once.
--
-Tim Hammerquist <timmy@cpan.org>
I do not, for one, think that the problem was that the band was down.
I think that the problem may have been...that there was a Stonehenge
monument on the stage that was in danger of being crushed by a dwarf.
-- David St. Hubbins, "This is Spinal Tap"
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 4450
**************************************