[10790] in Perl-Users-Digest
Perl-Users Digest, Issue: 4390 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 9 16:07:33 1998
Date: Wed, 9 Dec 98 13:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 9 Dec 1998 Volume: 8 Number: 4390
Today's topics:
Re: $|=0 (Greg Ward)
'use' is not threadsafe ? <mcariaso@genelogic.com>
Re: 'use' is not threadsafe ? <mcariaso@genelogic.com>
--- Problem sorting an array --- need help! <mitch@inquo.net>
Re: 3 perl cgi questions... (Michael Budash)
Another system() question <dejahvu@erols.com>
Re: Another system() question (brian d foy)
Re: Better way to get values from a list? <uri@ibnets.com>
Re: Better way to get values from a list? <tripp.lilley@perspex.com>
Re: Better way to get values from a list? (Larry Rosler)
Re: Can you use multiple formats? <dropzone@mail.utexas.edu>
Command line Perl works but IIS Perl doesn't rna16s@usa.net
Re: Decent Editor (Erik)
Re: Decent Editor scott@softbase.com
Re: Decent Editor <tony_mc@hotmail.com>
Re: Decent Editor <Allan@due.net>
Help on s/// !!! <lin@wdg.mot.com>
Re: Help on s/// !!! (brian d foy)
Re: Help on s/// !!! <uri@ibnets.com>
help with Chart module grindrod@tfn.com
How can I compare files? <pep_mico@hp.com>
Re: how to ensure script is only run by one user at a t (Greg Ward)
Re: how to get screen size? (Greg Bacon)
How to use prune in File::Find r_ramirez@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Dec 1998 20:30:54 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: $|=0
Message-Id: <74mmlu$2l3$1@news0-alterdial.uu.net>
Zenin <zenin@bawdycaste.org> wrote:
> Greg Ward <gward@thrak.cnri.reston.va.us> wrote:
> : No, that's wrong. $| = 1 sets your pipes to be piping hot, that is,
> : makes it so the currently selected output handle is unbuffered.
>
> Incorrect. It turns autoflush on, which isn't the same as
> unbuffered. You're still buffered, you're just being automatically
> flushed after every write. Use syswrite() and friends if you want
> real unbuffered writes, but be sure you know what you're doing first
> if you take this route.
Oops! My mistake -- thanks for pointing it out. To the original
poster, if you're still reading this: turning autoflush on ($| = 1)
*looks like* unbuffered output, but as Zenin pointed out, they are
subtly different. (Subtle enough that I goofed when posting my answer,
at least!)
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Wed, 09 Dec 1998 14:47:25 -0500
From: Mike Cariaso <mcariaso@genelogic.com>
Subject: 'use' is not threadsafe ?
Message-Id: <366ED3CD.E46D7431@genelogic.com>
For the p5ps and the others 'in the know'.
I think I've got a sufficiently small test program to illustrate this.
#!/usr/bin/perl -w
use Thread;
@mods = qw (
AnyDBM_File
AutoLoader
AutoSplit
Benchmark
CGI
CGI::Apache
CGI::Carp
CGI::Cookie
CGI::Fast
CGI::Push
CGI::Switch
CPAN
CPAN::FirstTime
CPAN::Nox
CPAN::Config
English
Env
Exporter
ExtUtils::Command
ExtUtils::Embed
ExtUtils::Install
ExtUtils::Installed
ExtUtils::Liblist
ExtUtils::MM_OS2
ExtUtils::MM_Unix
ExtUtils::MM_VMS
ExtUtils::MM_Win32
ExtUtils::MakeMaker
ExtUtils::Manifest
ExtUtils::Mkbootstrap
ExtUtils::Mksymlists
ExtUtils::Packlist
ExtUtils::testlib
ExtUtils::Miniperl
Fatal
File::Basename
File::CheckTree
File::Compare
File::Copy
File::DosGlob
File::Find
File::Path
File::Spec
File::Spec::Mac
File::Spec::OS2
File::Spec::Unix
File::Spec::VMS
File::Spec::Win32
File::stat
FileCache
FileHandle
FindBin
Getopt::Long
Getopt::Std
I18N::Collate
IPC::Open2
IPC::Open3
IPC::SysV
IPC::Msg
IPC::Semaphore
Math::BigFloat
Math::BigInt
Math::Complex
Math::Trig
Net::Ping
Net::hostent
Net::netent
Net::protoent
Net::servent
Pod::Functions
Pod::Html
Pod::Text
Search::Dict
SelectSaver
SelfLoader
Shell
);
sub load_some {
my ($i, $idx);
for ($i=0;$i<20;$i++) {
$idx = rand($#mods);
eval "use $mods[$idx]";
}
}
#play with the variations described below for a clearer picture
load_some;
new Thread \&load_some;
new Thread \&load_some;
new Thread \&load_some;
__END__
if the end is
load_some;
it works fine.
if the end is
new Thread \&load_some;
it segfaults.
if the end is
new Thread \&load_some;
new Thread \&load_some;
it sees mangled source code.
All tests were done on perl 5.0 patchlevel 5 subversion 2
compiled with -Dusethreads
under linux 2.0.36
--
"talking about music is like dancing about food"
Mike Cariaso (301) 987-1834
Software Engineer mcariaso@genelogic.com
Gene Logic, Inc. http://www.genelogic.com
------------------------------
Date: Wed, 09 Dec 1998 15:09:38 -0500
From: Mike Cariaso <mcariaso@genelogic.com>
Subject: Re: 'use' is not threadsafe ?
Message-Id: <366ED902.D2AF3F86@genelogic.com>
two more pieces of the puzzle.
#!/usr/bin/perl -w
use Thread;
sub sub1 {
print "loading1\n";
use CPAN;
use CPAN::FirstTime;
use CPAN::Nox;
use CPAN::Config;
use Exporter;
use ExtUtils::Command;
use ExtUtils::Embed;
use AutoLoader;
use AnyDBM_File;
use AutoSplit;
use ExtUtils::Installed;
}
sub sub2 {
print "loading2\n";
use CGI::Carp;
use CGI::Push;
use CGI::Switch;
use Exporter;
use ExtUtils::Command;
use ExtUtils::Embed;
use AutoLoader;
use AutoSplit;
use ExtUtils::Installed;
}
sub sub3 {
print "loading3\n";
use Benchmark;
use CGI;
use AutoLoader;
use Exporter;
use ExtUtils::Command;
use ExtUtils::Embed;
use CGI::Cookie;
use AutoLoader;
use AutoSplit;
use ExtUtils::Install;
use ExtUtils::Installed;
}
#sub1;
#sub2;
#sub3;
new Thread \&sub1;
new Thread \&sub1;
new Thread \&sub1;
new Thread \&sub2;
new Thread \&sub3;
__END__
runs just fine. suggesting the problem might be linked to the eval in
combination with the use?
#!/usr/bin/perl -w
use Thread;
sub sub1 {
print "loading1\n";
eval "use CPAN;";
eval "use CPAN::FirstTime;";
eval "use CPAN::Nox;";
eval "use CPAN::Config;";
eval "use Exporter;";
eval "use ExtUtils::Command;";
eval "use ExtUtils::Embed;";
eval "use AutoLoader;";
eval "use AnyDBM_File;";
eval "use AutoSplit;";
eval "use ExtUtils::Installed;";
}
sub sub2 {
print "loading2\n";
eval "use CGI::Carp;";
eval "use CGI::Push;";
eval "use CGI::Switch;";
eval "use Exporter;";
eval "use ExtUtils::Command;";
eval "use ExtUtils::Embed;";
eval "use AutoLoader;";
eval "use AutoSplit;";
eval "use ExtUtils::Installed;";
}
sub sub3 {
print "loading3\n";
eval "use Benchmark;";
eval "use CGI;";
eval "use AutoLoader;";
eval "use Exporter;";
eval "use ExtUtils::Command;";
eval "use ExtUtils::Embed;";
eval "use CGI::Cookie;";
eval "use AutoLoader;";
eval "use AutoSplit;";
eval "use ExtUtils::Install;";
eval "use ExtUtils::Installed;";
}
#sub1;
#sub2;
#sub3;
new Thread \&sub1;
new Thread \&sub1;
new Thread \&sub1;
new Thread \&sub2;
new Thread \&sub3;
__END__
hangs on my system. ctrl-C doesn't even work. in looking at the 'ps', there are
4 entries, the second of which is a zombie.
If anyone can make any sense of any of this...great. I'm using code similar to
my earlier post, to dynamically load modules. so either an eval/use or a
require seems to be necessary. Since it a real world project of considerable
size, this is flushing out quite a few threads 'issues'.
thanks a heap.
--
"talking about music is like dancing about food"
Mike Cariaso (301) 987-1834
Software Engineer mcariaso@genelogic.com
Gene Logic, Inc. http://www.genelogic.com
------------------------------
Date: Wed, 09 Dec 1998 13:11:58 -0700
From: Mitch Courtright <mitch@inquo.net>
Subject: --- Problem sorting an array --- need help!
Message-Id: <366ED98E.6A73@inquo.net>
I am having trouble with formatting a specific element of an array. The
goal is to append a file with data submitted from a form and have only
the first element formatted to a specific length. I want to be able to
sort the data later based on that first element. I'm very much a
beginner in PERL and haven't found an answer through other chanels.
Here's my code:
open (SCORESFILE, ">>scores.txt") die "$!";
@PAIRS = split("&", $buffer);
foreach $line (@PAIRS) {
($name, $value) = split("=", $line);
print SCORESFILE "$value!";
}
Here's the STDIN;
totalscore=13452&misses=65&time=128&name=Mitch Courtright&country=USA
Assuming there are already entries in the file this would produce a flat
db file as follows with the most recent entry appended at the end:
1245!24!76!Mitch Courtright!USA
100654!129!345!Mitch Courtright!USA
2593!35!45!Mitch Courtright!USA
13452!65!128!Mitch Courtright!USA
I want the first element to be 6 characters in length regardless of the
value. So I want it to print to the file this way:
1245!24!76!Mitch Courtright!USA
100654!129!345!Mitch Courtright!USA
2593!35!45!Mitch Courtright!USA
13452!65!128!Mitch Courtright!USA
That way, when the lines get sorted I can produce another sorted array
that would have elements 0..3 prepared for printing to another file as
follows:
1245!24!76!Mitch Courtright!USA
2593!35!45!Mitch Courtright!USA
13452!65!128!Mitch Courtright!USA
100654!129!345!Mitch Courtright!USA
Any help with a solution is appreciated. All I've been able to produce
so far is errors and runaway files! Here's the URL of what I have now
if you need more info:
http://www.xmission.com/~mcourtr/pbgermatch.html. It's a game of tile
matching using JS. I use a form to submit scores. When you submit a
score, you'll see what I mean.
Thanks.
=< Mitch.
=< E-mail: mailto:mitch@inquo.net
------------------------------
Date: Wed, 09 Dec 1998 12:06:16 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: 3 perl cgi questions...
Message-Id: <mbudash-0912981206160001@d59.nas1.napa.sonic.net>
comments embedded...
In article <366D3E6F.6FE7768A@hotmail.com>, "Christian H. Knudsen"
<chrknudsen@hotmail.com> wrote:
>> 1) Is it possible for a cgi perl script to check if a file
>> on a remote server server exists? Check the size?
>>
>> Ex.:
>> $exists = -e "http://www.blah.com/images/image.gif";
>> $size = -s "http://www.blah.com/images/image.gif";
>>
>> When I run these, the script can't find the designated
>> file. (Naturally I have tested these on files that _do_
>> exist...)
check out the LWP perl module. it'll do what you want, though it's a
little more wordy to use than your example...
>> 2) Is it possible to check the dimensions of an image
>> file (width x height)?
don't know, sorry...
>> 3) How do you make a script that first reads/writes to
>> some files, then reloads a new page?
>>
>> Ex.:
>> open (FILE, "...");
>> .
>> .
>> .
>> close (FILE);
>> print "Location: http://www.blah.com";
>>
>> When I run this I get a "Premature end of script headers" error.
>> I guess this is because the lack of a "Content-type: ..." header.
>> But, if I include such a header the "Location: ..." header is
>> simply printed on the screen!
>> I've thought about simply reading the file of the page I want to
>> reload and then "print" line by line. But this doesn't change the
>> URL location...
you need to complete your http header with 2 newlines, e.g.:
print "Location: http://www.blah.com\n\n";
hth-
@-------------------------------@------------------------@
| Michael Budash Consulting | 707-255-5371 |
| Perl, Javascript, Html, mSQL | 707-258-7800 x7736 |
| Official Extropia Developer | mbudash@sonic.net |
@-------------------------------@------------------------@
------------------------------
Date: Wed, 09 Dec 1998 13:14:53 -0600
From: Mary E Tyler <dejahvu@erols.com>
Subject: Another system() question
Message-Id: <366ECC2B.13FD@erols.com>
I am thinking of using an external c program (external to my perl
program that is) to do something and spit back a result. A few
questions:
1) if the call to system is made
system(myprogram.c, "@arguements")
how will the arguements arrive at the c program? will the c program see
them as individual items in the ARGV array or will the perl array be
crammed into the c array somehow?
2) what is the mechanicsm for returning information (if there is one) to
the calling perl program?
thanks for your time,
dejah
--
i trust i make myself obscure, i have need of obscurity now- robert bolt
a heated exchange of unread mail would be welcomed by all- christensen
Skating Fiction. Featuring the highly acclaimed serial On The Edge!
http://www.DejahsPrivateIce.com
------------------------------
Date: Wed, 09 Dec 1998 15:20:06 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Another system() question
Message-Id: <comdog-ya02408000R0912981520060001@news.panix.com>
In article <366ECC2B.13FD@erols.com>, dejahvu@erols.com posted:
> I am thinking of using an external c program (external to my perl
> program that is) to do something and spit back a result. A few
> questions:
>
> 1) if the call to system is made
>
> system(myprogram.c, "@arguements")
you could just as well do
system 'myprogram.c', @arguments;
no need to interpolate them inside a string and have a wierd $"
mess up your day.
> 2) what is the mechanicsm for returning information (if there is one) to
> the calling perl program?
see the perlipc manpage for several ways to capture the output of
other processes. :)
--
brian d foy <brianNOSPAM@NOSPAM.smithrenaud.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
remove NOSPAM or don't. it doesn't matter either way.
------------------------------
Date: 09 Dec 1998 14:59:29 -0500
From: Uri Guttman <uri@ibnets.com>
To: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Better way to get values from a list?
Message-Id: <39r9u9rsri.fsf@ibnets.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>> who are you calling an imaginative monster? :-)
LR> If the shoe fits... :-)
who are you saying wears shoes?
LR> So two loops are faster than one! The key must be that the marginal
LR> cost of looping inside the regex is much less than the initialization
LR> cost of launching a regex match for each operand. That is certainly
LR> instructive.
that is what i have learned from various sources. it is more the perl op
dispatch loop that is slow. internal loops (join, m//g) are done a c
speeds and is only 2 perl ops. doing a map on m// is invoking a perl op
per iteration. lowering perl ops is a known way to speed things up, even
if the code may look counterintuitive.
LR> Benchmark: timing 65536 iterations of Join, Map, Push...
LR> Join: 5 wallclock secs ( 4.56 usr + 0.00 sys = 4.56 CPU)
LR> Map: 5 wallclock secs ( 5.00 usr + 0.00 sys = 5.00 CPU)
LR> Push: 10 wallclock secs ( 8.92 usr + 0.00 sys = 8.92 CPU)
LR> He, he. It got slower (though more correct)! Evidently the time to
LR> clear the target array on each loop through the benchmark outweighs the
LR> 'lots of reallocs'. I don't see why there would be 'lots of reallocs'
LR> in any case. Assuming each is done reasonably (doubling the allocated
LR> size each time), the number of reallocs should be logarithmic, not
LR> linear. So there are few reallocs, but lots of resets.
true, i forgot about the doubling algorithm. instructive in any case.
maybe instead of clearing the array, you used subs in the bench with the
results being a my var, it might get created faster than explicitly
clearing it. but then i has to be freed for each call too. you could
make all the tests use a sub with the same declaration to get a more
accurate comparison of the actual algorithm. i have also seen dummy subs
used to get a baseline to subtract from the other real tests.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ibnets.com
------------------------------
Date: Wed, 09 Dec 1998 15:25:34 -0500
From: Tripp Lilley <tripp.lilley@perspex.com>
Subject: Re: Better way to get values from a list?
Message-Id: <366EDCBD.2BFED5C8@perspex.com>
Matthew Bafford wrote:
> Benchmark: timing 65536 iterations of Join, Map, Push, RPush...
> Join: 6 wallclock secs ( 6.59 usr + 0.00 sys = 6.59 CPU)
> Map: 6 wallclock secs ( 6.26 usr + 0.00 sys = 6.26 CPU)
> Push: 12 wallclock secs (11.42 usr + 0.00 sys = 11.42 CPU)
> RPush: 22 wallclock secs (21.25 usr + 0.00 sys = 21.25 CPU)
>
> The exact opposite of what I expected.
As Larry pointed out, the cost of clearing the target array is significant.
The numbers are much closer to the original benchmark when that's factored
out. Note that thrashing /does/ play a pretty big part, but not just in the
way you might suspect. It took nearly 27 seconds to cleanup after this bench,
before perl would exit! Note also the jump between 2^^17 and 2^^18 iterations
-- the Push version took nearly 30% longer than it did for fewer iterations.
All benching on P2-400/128MB NT 4.0SP3, AP 507 (5.005_02)
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my @a = qw(one two a=b c=d three e=f);
my @join_result = ( );
my @map_result = ( );
my @push_result = ( );
timethese ( (1 << (shift || 0) ), {
Join => sub { @join_result = join( "\n", @a ) =~ m/=(.+)$/mg },
Map => sub { @map_result = map /=(.*)/, @a },
Push => sub { foreach (@a) { push @push_result, $1 if /=(.*)/ } },
} );
__END__
X:\PROJECTS\scratch>perl bench 16
Benchmark: timing 65536 iterations of Join, Map, Push...
Join: 2 wallclock secs ( 2.23 usr + 0.00 sys = 2.23 CPU)
Map: 3 wallclock secs ( 2.39 usr + 0.00 sys = 2.39 CPU)
Push: 4 wallclock secs ( 3.85 usr + 0.09 sys = 3.94 CPU)
X:\PROJECTS\scratch>perl bench 18
Benchmark: timing 262144 iterations of Join, Map, Push...
Join: 9 wallclock secs ( 8.90 usr + 0.00 sys = 8.90 CPU)
Map: 9 wallclock secs ( 9.60 usr + 0.00 sys = 9.60 CPU)
Push: 24 wallclock secs (15.99 usr + 0.33 sys = 16.32 CPU)
X:\PROJECTS\scratch>perl bench 17
Benchmark: timing 131072 iterations of Join, Map, Push...
Join: 4 wallclock secs ( 4.45 usr + 0.00 sys = 4.45 CPU)
Map: 4 wallclock secs ( 4.83 usr + 0.00 sys = 4.83 CPU)
^C
X:\PROJECTS\scratch>perl bench 17
Benchmark: timing 131072 iterations of Join, Map, Push...
Join: 5 wallclock secs ( 4.43 usr + 0.00 sys = 4.43 CPU)
Map: 5 wallclock secs ( 4.80 usr + 0.00 sys = 4.80 CPU)
Push: 8 wallclock secs ( 7.84 usr + 0.04 sys = 7.88 CPU)
X:\PROJECTS\scratch>perl bench 18
Benchmark: timing 262144 iterations of Join, Map, Push...
Join: 10 wallclock secs ( 8.89 usr + 0.00 sys = 8.89 CPU)
Map: 10 wallclock secs ( 9.59 usr + 0.00 sys = 9.59 CPU)
Push: 22 wallclock secs (15.92 usr + 0.26 sys = 16.18 CPU)
------------------------------
Date: Wed, 9 Dec 1998 12:34:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Better way to get values from a list?
Message-Id: <MPG.10d87ec1b673280f9898b5@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <39r9u9rsri.fsf@ibnets.com> on 09 Dec 1998 14:59:29 -0500,
Uri Guttman <uri@ibnets.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>
> >> who are you calling an imaginative monster? :-)
>
> LR> If the shoe fits... :-)
>
> who are you saying wears shoes?
If you don't even use upper-case letters, why should I assume you wear
shoes? If the sandal fits...
> LR> Benchmark: timing 65536 iterations of Join, Map, Push...
> LR> Join: 5 wallclock secs ( 4.56 usr + 0.00 sys = 4.56 CPU)
> LR> Map: 5 wallclock secs ( 5.00 usr + 0.00 sys = 5.00 CPU)
> LR> Push: 10 wallclock secs ( 8.92 usr + 0.00 sys = 8.92 CPU)
...
> maybe instead of clearing the array, you used subs in the bench with the
> results being a my var, it might get created faster than explicitly
> clearing it. but then i has to be freed for each call too. you could
> make all the tests use a sub with the same declaration to get a more
> accurate comparison of the actual algorithm.
So could you. However...
> i have also seen dummy subs
> used to get a baseline to subtract from the other real tests.
#!/usr/local/bin/perl -w
use Benchmark;
@a = qw(one two a=b c=d three e=f);
timethese ( (1 << (shift || 0) ), {
Cntrl => sub { my @b = @a },
Join => sub { my @b = join( "\n", @a ) =~ m/=(.+)$/mg },
Map => sub { my @b = map /=(.*)/, @a },
Push => sub { my @b; foreach (@a) { push @b, $1 if /=(.*)/ } },
} );
__END__
Benchmark: timing 65536 iterations of Cntrl, Join, Map, Push...
Cntrl: 3 wallclock secs ( 2.83 usr + 0.00 sys = 2.83 CPU)
Join: 5 wallclock secs ( 4.56 usr + 0.00 sys = 4.56 CPU)
Map: 5 wallclock secs ( 5.02 usr + 0.00 sys = 5.02 CPU)
Push: 8 wallclock secs ( 9.59 usr + 0.00 sys = 9.59 CPU)
Worse and worse for Push! Definitely Not The Best Way To Do It.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 09 Dec 1998 14:13:43 -0600
From: Forrest Reynolds <dropzone@mail.utexas.edu>
Subject: Re: Can you use multiple formats?
Message-Id: <366ED9F6.95B6D8B2@mail.utexas.edu>
Forrest Reynolds wrote:
>
> Is it possible to define and use two or more FORMAT statements in a
> program, not including FORMAT_TOP, footers, etc.?
>
> I can't get it to work. I'm trying add subtotals to a program that
> didn't have them and I want to use something like this:
>
> format LOGREPORT =
> ~ @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> $print_dest
> ~@< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>
> @>>>>>
> $save_src_state, $save_src_name, $total_transcr, $total_acknowl
> ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> $other_codes
> .
> format SUBTOTAL =
> ~ @>>>>>>>>> @>>>>>
> @>>>>>
> $subtotal, $dotty, $dotty
> ~ @>>>>>
> @>>>>>
> $subtotal_t, $subtotal_a
> .
Here's the code I have so far:
select(LOGREPORT);
$~ = "SUBTOTAL";
write SUBTOTAL;
select(LOGREPORT);
$~ = "LOGREPORT";
>
> Thanks, Forrest
------------------------------
Date: Wed, 09 Dec 1998 19:53:47 GMT
From: rna16s@usa.net
Subject: Command line Perl works but IIS Perl doesn't
Message-Id: <366ed4f2.99137432@news.randori.com>
Hello All,
Hello All,
I am trying to run a script using the LWP Perl module on IIS 4 NT
Server. I have installed Active State 5.07 Perl and set up the mapping
in IIS. The problem I am having is the script I am running (which goes
out and grabs a URL and the prints out the HTML source) throws an
error when trying to tun the script through the web browser, but the
command line works fine. This is the script
*********** Start Script ******************
# Create a user agent object
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);
# Create a request
my $req = new HTTP::Request GET => 'http://www.yahoo.com';
#$req->content_type('text/html');
#$req->content('index.html');
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
} else {
print "Bad luck this time\n";
}
*********** End Script ******************
This script returns the html for the url (Yahoo in this case) no
problem from the command line, but from the browser it throws the
error condition and prints "Bad Luck this time". I am new to modules
and Perl/IIS. Any help would be appreciated. Thanks.
-Derek
------------------------------
Date: 9 Dec 1998 19:00:03 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Decent Editor
Message-Id: <74mhbj$vhb$1@news.cyberhighway.net>
In article <913227905.944812@thrush.omix.com>,
Zenin <zenin@bawdycaste.org> writes:
> Normally for code editors I suggest joe (Joe's Own Editor), Emacs,
> and vim (*not* ever plain vi for code editing), in that order. I'm
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Don't EVER say anything like this again. It's not that I disagree with
you (although I do), it's that you're getting dangerously close to
starting yet another editor war.
--
Erik Nielsen, Cyberhighway Internet Services NOC
I've found that nurturing one's Zen nature is vital to dealing with
technology. Violence is pretty damn useful too.
-- Lionel Lauer in a.s.r.
------------------------------
Date: 9 Dec 1998 20:42:54 GMT
From: scott@softbase.com
Subject: Re: Decent Editor
Message-Id: <366ee0ce.0@news.new-era.net>
Antony (amcnulty@nortel.co.uk) wrote:
> I'd really like to have an editing program for my PERL scripts that shows
> each subroutine as different pages, or something similar to that.
Emacs has "folding" capabilities. It's kind of similar.
Scott
------------------------------
Date: Wed, 9 Dec 1998 19:38:26 -0000
From: "Antony McNulty" <tony_mc@hotmail.com>
Subject: Re: Decent Editor
Message-Id: <74mjie$r2g$1@bcarh8ab.ca.nortel.com>
OK people calm down, let's not get worked up here....
I'm on a Windows platform, have access to a UNIX platfom, but prefer to use
Windows.
I noticed many editors mentioned were UNIX, any ideas for the PC then ??
Cheers
Antony
P.S, chill out guys....
Erik wrote in message <74mhbj$vhb$1@news.cyberhighway.net>...
:In article <913227905.944812@thrush.omix.com>,
: Zenin <zenin@bawdycaste.org> writes:
:> Normally for code editors I suggest joe (Joe's Own Editor), Emacs,
:> and vim (*not* ever plain vi for code editing), in that order. I'm
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:Don't EVER say anything like this again. It's not that I disagree with
:you (although I do), it's that you're getting dangerously close to
:starting yet another editor war.
:
:--
:Erik Nielsen, Cyberhighway Internet Services NOC
:I've found that nurturing one's Zen nature is vital to dealing with
:technology. Violence is pretty damn useful too.
: -- Lionel Lauer in a.s.r.
------------------------------
Date: Wed, 9 Dec 1998 15:20:40 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Decent Editor
Message-Id: <74mliu$8og$1@camel25.mindspring.com>
Antony McNulty wrote in message <74mjie$r2g$1@bcarh8ab.ca.nortel.com>...
>OK people calm down, let's not get worked up here....
>I'm on a Windows platform, have access to a UNIX platfom, but prefer to use
>Windows.
>I noticed many editors mentioned were UNIX, any ideas for the PC then ??
>Cheers
>Antony
Well, I say this all the time but I quite like UltraEdit. Macros, column
mode, colored syntax, view html your are editing with your browser, etc.
Plus it is easy to set up a tool that allows you to run Perl from within
UltraEdit and then capture the output to either a list box or a new file in
the editor. You can also run DOS commands from within the editor. It is
shareware and times out after something like 30-45 days, I forget which.
For me, it is well worth the money. Oh, new feature, it now has it's own
FTP capability. Just my $.02.
AmD
------------------------------
Date: Wed, 09 Dec 1998 10:59:35 -0800
From: Brandon Lin <lin@wdg.mot.com>
Subject: Help on s/// !!!
Message-Id: <366EC897.F4A05F5@wdg.mot.com>
Hi all,
This might sound stupid, but it really beats me.
There's a line like the following.
......blablabla..........<TD><!--increment
here-->1</TD>........blablabla......
and it should be changed to
......blablabla..........<TD><!--increment
here-->2</TD>........blablabla......
I tried
$line=~s/<!--increment here-->(\d+)/<!--increment here-->$1+1/e
$line=~s/<!--increment here-->(\d+)/sprintf("<!--increment
here-->$1+1")/e
and none of them worked.
Any ideas?
Regards,
Brandon
------------------------------
Date: Wed, 09 Dec 1998 15:03:22 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Help on s/// !!!
Message-Id: <comdog-ya02408000R0912981503220001@news.panix.com>
In article <366EC897.F4A05F5@wdg.mot.com>, lin@wdg.mot.com posted:
> $line=~s/<!--increment here-->(\d+)/<!--increment here-->$1+1/e
> $line=~s/<!--increment here-->(\d+)/sprintf("<!--increment
> here-->$1+1")/e
>
> and none of them worked.
close. here's what you wanted:
$\ = "\n";
$_ = '<td>foofoocon baz bar <!--increment here-->1</td>';
print;
for ($i=0;$i<5;$i++)
{
s/<!--increment here-->(\d+)/
sprintf "<!--increment here-->%d", $1 + 1
/e;
print;
}
--
brian d foy <brianNOSPAM@NOSPAM.smithrenaud.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
remove NOSPAM or don't. it doesn't matter either way.
------------------------------
Date: 09 Dec 1998 15:09:51 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Help on s/// !!!
Message-Id: <39ogpdrsa8.fsf@ibnets.com>
>>>>> "BL" == Brandon Lin <lin@wdg.mot.com> writes:
BL> ......blablabla..........<TD><!--increment
here--> 1</TD>........blablabla......
BL> ......blablabla..........<TD><!--increment
here--> 2</TD>........blablabla......
BL> $line=~s/<!--increment here-->(\d+)/<!--increment here-->$1+1/e
BL> $line=~s/<!--increment here-->(\d+)/sprintf("<!--increment
here--> $1+1")/e
with /e the replacement is a true perl expression. neither example of
yours is a proper expression to get what you want. in fact, the first
own looks like a syntax error to me.
try this (untested but probably good):
$line =~ s/(<!--increment here-->)(\d+)/$1 . ($2+1)/e ;
this doesn't handle wrapped text (embedded newlines) which you show in
your examples (that mey be wrapped from your mailer) but that can be
fixed with use of \s+ instead of the blanks.
hth,
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ibnets.com
------------------------------
Date: Wed, 09 Dec 1998 19:38:49 GMT
From: grindrod@tfn.com
Subject: help with Chart module
Message-Id: <74mjk9$k71$1@nnrp1.dejanews.com>
This is my first time trying to chart data. I would like to use the Chart
modual, but dont't really know where to start and am hoping someone can me an
example bassed on the below data.
Using the below data file I want to create a bar graph for ea. of the 3
machines below with the bars representing the percent of disk available. Each
file system needs have 5 bars(one for ea business day) If the space is over
80 the bar should be orange, if over 90 sould be red, else s/b green.
Below is one day of data(the real thing would have 5 days for each machine.
So, for the data below, "willow" is the machine. The x data labels s/b
date+filesystem for each bar on the graph. the y axis will show percent in
increments of 5..100. The title for ea. graph s/b the machine name.
The result s/b 3 seperate bar graphs for each machine displayed on a web
page, each with 5 bars(5 days of data) for each file system on the machine.
This will make a good system admin tool for monitoring trends in disk usage.
machine date capacity filesystem
willow 1998-12-9 23 / willow 1998-12-9 74 /usr willow 1998-12-9 50
/var willow 1998-12-9 33 /home willow 1998-12-9 27 /opt willow 1998-12-9
1 /tmp willow 1998-12-9 49 /usr/local/sybase willow 1998-12-9 93
/usr/local/sybase/tempdb willow 1998-12-9 35 /datadump willow 1998-12-9
32 /alert willow 1998-12-9 56 /home/mint
monet 1998-12-9 81 / monet 1998-12-9 62 /usr monet 1998-12-9 48 /var
monet 1998-12-9 46 /opt monet 1998-12-9 1 /tmp monet 1998-12-9 78
/usr/local/sybase monet 1998-12-9 48 /datadump monet 1998-12-9 90
/usr/local/sybase/tempdb monet 1998-12-9 53 /oadatadump
picasso 1998-12-9 80 /
picasso 1998-12-9 82 /usr picasso 1998-12-9 41 /var
picasso 1998-12-9 22 /opt picasso 1998-12-9 1 /tmp
picasso 1998-12-9 98 /sb
picasso 1998-12-9 24 /oasysdump
I am very interested in hearing from anyone who knows how to do this or has
some better examples, that I can look at. Please email me at: grindrod@tfn.com
Thanks in advance
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 09 Dec 1998 20:00:31 +0100
From: Pep Mico <pep_mico@hp.com>
Subject: How can I compare files?
Message-Id: <366EC8CF.A1B4FF9F@hp.com>
Hello,
I'm using Perl under Windows NT. How can I compare two files? I haven't
found this file function in Perl Manuals. I just only need to know if
files are Equals or differents.
Should I invoke COMP command from Windows NT?
Regards
pep_mico@hp.com
------------------------------
Date: 9 Dec 1998 20:51:55 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: how to ensure script is only run by one user at a time
Message-Id: <74mntb$2l3$3@news0-alterdial.uu.net>
23_skidoo <23_skidoo@geocities.com> wrote:
> i'm writing a cgi script which opens and updates a number of files, if
> two people run this script simultaneously it can lead to errors. while
> this doesn't happen very often as the script runs quite quickly, i'd
> like to avoid it happening at all and would like one of the users to
> have to wait until the other user has finished.
>
> would an acceptable way to do this be to open and lock a file at the
> start of the script and unlock it again at the end? this could be a
> non-related file that didn't need to be read or written to but would
> just serve as a way to hold up user #2.
>
> will this work, is it a good idea or would it make me the king of cruft?
> any other suggestions?
That should work, but you don't necessarily have to lock the sentinel
file; just consider the file's existence as a lock against running the
script.
Heck, if you've got file locking, why not use it on the parts of the
script where multiple invocations cause problems? Usually, the primitive
"file existence test as lock" hack is only needed on deficient systems with
no locking, or by deficient software that can't be bothered to properly
lock its sensitive files.
Also, if you do take the easy way out and make a sentinel file, be sure
to clean it up if your script dies unexpectedly! END {} and
SIG{'__DIE__'}, and possibly eval {} are your friends. RTFM to
understand the exact interactions between them -- it can be a bit hairy
to make sure you've covered every case, and it depends on which of them
you choose to use.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 9 Dec 1998 20:02:20 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: how to get screen size?
Message-Id: <74ml0c$346$1@info.uah.edu>
In article <366EAE19.F65AE514@hknet.com>,
Rollo Chan <rollo@hknet.com> writes:
: I am a 'fresh guy' of using perl.....I would like to ask....while using
: perl under UNIX...how to get the current terminal screen size by
: perl??.......I mean how to get the column number of the screen in order
: to adjust the output to fit the screen...thanks of all of your help.....
>From Recipe 15.4 of the Perl Cookbook (pg 521):
use Term::ReadKey;
($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize();
Hope this helps,
Greg
--
Seminars, n.: From 'semi' and 'arse', hence, any half-assed discussion.
------------------------------
Date: Wed, 09 Dec 1998 20:14:20 GMT
From: r_ramirez@my-dejanews.com
Subject: How to use prune in File::Find
Message-Id: <74mlmq$m6k$1@nnrp1.dejanews.com>
I am having trouble understanding the subtlety of using
prune with File::Find. I've read what I could find in
PerlFAQ, perldoc, the camel and llama books, and
http://www.stonehenge.com/merlyn/UnixReview/col16.html
File::File looks like a useful tool but I don't
understand how to use it enough to turn on File::Find::prune.
This is the last iteration of my script...
#!/usr/local/bin/perl -w
use File::Find;
sub wanted {
-T &&
-s > 5120 &&
push(@files, $File::Find::name) &&
($File::Find::prune = 1);
}
find (\&wanted, '.');
foreach (sort @files) { print "$_\n"; }
exit;
It runs but it also lists files passing the tests that
are in the subdirectories. I would appreciate anyone to try
to explain what I am doing wrong or point me to more
information. (BTW, I'm running this on a unix box.)
TIA, rr
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4390
**************************************