[18072] in Perl-Users-Digest
Perl-Users Digest, Issue: 232 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 7 11:05:40 2001
Date: Wed, 7 Feb 2001 08:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981561910-v10-i232@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 7 Feb 2001 Volume: 10 Number: 232
Today's topics:
Re: * Perl vs. Java in high-traffic Website * (Nick Condon)
\ versus / on Win32. <prsa@cntw.com>
Re: a bug in perl-5.6.0? <morozov@novosoft.ru>
Re: a bug in perl-5.6.0? <morozov@novosoft.ru>
about dying <emelin@my-deja.com>
Re: Ada feature borrowed for Perl?? <mischief@velma.motion.net>
Big Numbers <skorpik@yoyo.pl>
Re: Deleting Unnecessary Lines and Spaces in HTML (Chris Fedde)
Do cookies work in IE 4 and below? mstorti@my-deja.com
Re: don't want to let them enter & and = ... <joe+usenet@sunstarsys.com>
Re: don't want to let them enter & and = ... (Randal L. Schwartz)
Re: Fastest way of left-padding a number? <ccx138@coventry.ac.uk>
Re: Fastest way of left-padding a number? <jll63@easynet.be>
Re: Hashes aramis1631@my-deja.com
Re: hex to binary conversion ? Please help <mjcarman@home.com>
Re: hex to binary conversion ? Please help (Peter J. Acklam)
Re: how to remove item in the array? philhibbs@my-deja.com
Re: how to remove item in the array? tanase_costin@my-deja.com
Re: Linux does reclaim memory from perl <mischief@velma.motion.net>
Re: Logfile pattern search & print mgrime@my-deja.com
Re: Need advice: choosing between C++ CGI, Java servlet <bkennedy99@Home.com>
Re: Need Help Checking IP Address Syntax w/ PERL? <webbgroup@my-deja.com>
newbie: running script from a wrapper script in cron <sh56649@uta.fi>
Re: Package question <bkennedy99@Home.com>
perlcc fails on Windows 2000 <amosshapira@my-deja.com>
Re: Radical readdir suggestion <iltzu@sci.invalid>
Re: regexp for splitting up file paths? <chris.burn@bigfoot.com>
waiting for a file to be created <peterca@ukgateway.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Feb 2001 14:56:10 GMT
From: nickco3@yahoo.co.uk (Nick Condon)
Subject: Re: * Perl vs. Java in high-traffic Website *
Message-Id: <904197C2ENickCondon@132.146.16.23>
cut_here.retoh@dplanet.ch (Reto Hersiczky) wrote in
<Xns903D779016001cuthereretohdplanetc@195.186.1.107>:
>
>! Need *your* opinion !
>
>
>"Some guys explain to a customer: Websites from <that> kind of traffic
> meet the edge of running dynamic pages with Perl. They sugguest to
> make future developments in pure Java."
>
>
>Technical Conditions:
>
>- Apache Webserver
>- Sun Solaris
>- Postgres database, ~ 15 Tables, < 50000 rows
>- Web traffic approximately 25000 page views per hour
>
>
>I assume the reason for their advise lies in the fact it is easyer
>to protect the intellectual property with Servlets rather than
>deploying a script where the customer becomes the ability to read code.
That's Javascript. Perl is executed on the server and the client never sees
it.
--
Nick
------------------------------
Date: Wed, 07 Feb 2001 16:36:28 +0100
From: Per Sandberg <prsa@cntw.com>
Subject: \ versus / on Win32.
Message-Id: <3A816B7C.95E007C2@cntw.com>
Hi!
I am tryin to import modules from CPAN into my WindowsNT box and the
makefile.pl produces a makefile with "\" as directory delimiter,
this is not compatible with make GNU variant.
The question is:
How to have the "makefile.pl" to produce usable makefiles.
/Per Sandberg
/SAAB Tech systems
------------------------------
Date: 7 Feb 2001 14:18:01 GMT
From: Alexey Morozov <morozov@novosoft.ru>
Subject: Re: a bug in perl-5.6.0?
Message-Id: <95rlep$2it6$1@news.itfs.nsk.su>
Chris Stith <mischief@velma.motion.net> wrote:
Thank you much for you explanations.
------------------------------
Date: 7 Feb 2001 15:27:40 GMT
From: Alexey Morozov <morozov@novosoft.ru>
Subject: Re: a bug in perl-5.6.0?
Message-Id: <95rphc$2la8$1@news.itfs.nsk.su>
I have reviewed your message once again and would like to ask you additional
questions if you don't mind :-)
Chris Stith <mischief@velma.motion.net> wrote:
CS> {
CS> $_ .= "null", last SWITCH unless defined $_;
CS> $_ .= $_, last SWITCH if ($_ eq 'a');
CS> $_ .= ", wow!", last SWITCH if ($_ eq 'b');
CS> $_ .= " default";
Well, that's what I read in perl docs for map:
map EXPR,LIST
Evaluates the BLOCK or EXPR for each element of
LIST (locally setting $_' to each element) and
returns the list value composed of the results of
^^^^^^^^^^^^^^
each such evaluation.
....
Note that, because $_' is a reference into the
list value, it can be used to modify the elements
^^^^^^
of the array.
...
Initially I didn't wish to alter the original array. Your code also alters
@array. This isn't what I originally want to.
CS> Turn on warnings.
Yes, you're completely right.
CS> This is more broken than the already broken code above.
CS> The map() function expects its code block to return
CS> something.
AFAIK, the value returned is the result of a last operation either it was a
$_ assigning or just an exit code of a function call. So I thought (before
faced the error) "place there an expression and it would be enough for
everything". From this point of view I still don't see difference between
"null" and undef."null" (except of the perl warning of course).
CS> Altering q<$_> is somewhat equivalent to returning something,
...
CS> Those are the right results. You don't assign anything to
CS> q<$_> on that line, so it is still undefined. If you map
I think you're right when you say that altering $_ also sets the block exit
(return) code but I thought this is not _required_ to form such code.
I can illustrate this by next (correct from perl view example)
-----------------------------------
use strict;
use diagnostics;
my @array = ('a','b',undef,'c','d');
my @results = map {
my $a;
SWITCH:
{
$a = "null", last SWITCH unless defined $_;
$a = $_.$_, last SWITCH if ($_ eq 'a');
$a = $_.", wow!", last SWITCH if ($_ eq 'b');
$a = $_." default";
}
$a;
} @array;
print "Results: ('".join("', '",@results)."')\n";
-----------------------------------
We never alter $_ here, but nevertheless it works. We even can exclude that
'$a;' string, it still works correctly. (BTW, initially I had a code like
this but this assigning seemed useless and I left only right parts of the
expressions)
CS> Warnings are your friend. The diagnostics module can help
CS> you, too, but warnings should come first in troubleshooting,
Sure. You're right. Actually I did have #!/usr/bin/perl -w
in the first line, and saw warnings but considered them non-significant
here :-(
I forgot about diagnostics however. Thank you for pointing me on it.
------------------------------
Date: Wed, 07 Feb 2001 14:25:43 GMT
From: emelin <emelin@my-deja.com>
Subject: about dying
Message-Id: <95rlst$dej$1@nnrp1.deja.com>
simply writing
die "Error!";
the way I've learned it doesn't show anything if I run the program from
my www browser... it seems to work if I write
die print "Error!";
Is this also a correct way to do it?
Why doesn't die work as is??
I read something here about die messages going to the server log
somehow... does this have something to do with it? Shouldn't you also
be able to view it from your browser??
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 07 Feb 2001 15:31:31 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Ada feature borrowed for Perl??
Message-Id: <t82qijgckem259@corp.supernews.com>
Hessu <qvyht@iobox.fi> wrote:
> Misanthrope wrote:
>>
>> Ada has two different keywords that deal with packages.
[snip]
>
>> <gdemont@my-deja.com> wrote in message news:91cu9j$kkl$1@nnrp1.deja.com...
>> >
>> > > Does Ada use 'use' to use packages?
>> >
[snip]
> Java-like!
> Java is Ada without marketing errors...
That's an evil thing to say about Java. Ada had great marketing,
as a matter of fact. The US Department of Defense mandated it for
use in all their programming needs for a time. You can't get much
better marketing than that, considering how many lines of code
that department has in use.
The reason Ada has not done very well is that it's too ornate and
cumbersome. It does have good features, but it has too many
different features in too many different directions. It's too much
like Pascal, which has a horrible type system. A smaller subset of
Ada would probably make a good language.
Perl also has many features from many sources, but they are all
focused in more or less the same direction. The number of keywords
in Perl is high and some overlap exists, However, they are all
focused on getting the job done instead of enforcing style and you
don't have to know all of them to get most of your tasks done. As
Larry says, (possibly I'm paraphrasing)... "easy things should be
easy and difficult things should be possible". This is the case
most of the time with Perl, not so with Ada.
Chris
--
Christopher E. Stith
Parking for people we like only. All other vehicles will be vandalized.
------------------------------
Date: Wed, 07 Feb 2001 16:33:10 +0100
From: Slasia <skorpik@yoyo.pl>
Subject: Big Numbers
Message-Id: <3A816AB6.E80C3BA7@yoyo.pl>
Hi !
I have this problem.
Perl Script !
#-------------------------------
use strict;
my $sNumber = 0;
my $sResult = 0;
# It is good for 31, for 32 i isn`t
my $sPowElem = 31;
$sNumber = 2**$sPowElem;
print "2**$sPowElem = $sNumber\n";
# Mark bit
$sResult |= $sNumber;
print "Result = $sResult\n";
#-------------------------------
What can I solve my problem for $sPowElem > 31 ?
Thanks
L
------------------------------
Date: Wed, 07 Feb 2001 15:22:10 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Deleting Unnecessary Lines and Spaces in HTML
Message-Id: <CKdg6.129$M8.170963968@news.frii.net>
In article <3A816BDE.FAA4C29E@ev1.net>, AmSkape <amskape@ev1.net> wrote:
>I am writing a script that reads html pages into a scalar one line at a
>time. It works except for when I run into a situation where an html line
>
>is broken into multiple lines like so:
><p>This is a
> line</p>
>I would like this to be read into the variable as a single line as
>opposed to two. I have tried substituting newline ("\n") with a space.
>It helps with some lines but not with others. Is there a module that
>formats html properly without unecessary newlines? Any help is greatly
>apreciated.
>
Look for modules on CPAN that have the word HTML and Pretty in their title.
There are a few. Also look at the tidy utility from
http://www.w3.org/People/Raggett/tidy/
good luck
chris
--
This space intentionally left blank
------------------------------
Date: Wed, 07 Feb 2001 15:48:22 GMT
From: mstorti@my-deja.com
Subject: Do cookies work in IE 4 and below?
Message-Id: <95rqo2$hul$1@nnrp1.deja.com>
Hi,
I am somehwat confused with the behaviour of
cookies in MS Explorer
versions 4 and below. I wrote a CGI script that
uses cookies and works
fine in Netscape but it seems that Explorer 4
doesn't store te
cookie. For instance the script "cokie.cgi" that
comes with the
distribution doesn't work with MSIE 4. Yes, I
know, there is a nice
banner saying "This script only works with
Netscape browsers", but in
the doc it says:
> HTTP COOKIES
>
> Netscape browsers versions 1.1 and higher, and
all versions of
> Internet Explorer, support a so-called
``cookie'' designed to help
> maintain state within a browser session. CGI.pm
has several methods
> that support cookies.
Also, IE has a configuration entry related to
"accept cookies" or
something like that, so that I am somewhat
confused about whether MSIE
manages cookies or not.
Any help is welcome!
Regards,
Mario
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 07 Feb 2001 09:07:39 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: don't want to let them enter & and = ...
Message-Id: <m3snlqr3h0.fsf@mumonkan.sunstarsys.com>
emelin <emelin@my-deja.com> writes:
> I'm using the code below to fetch contents from a form. But if the user
> enters & or = I encounter problems later on...
Why? Isn't this a CGI script? Those characters should be url-encoded
by the browser.
> things don't split right... how do I check this before this code has
> split the contents??
You don't; use CGI.pm instead and forget about it.
--
Joe Schaefer "This isn't right, this isn't even wrong."
-- Wolfgang Pauli
------------------------------
Date: 07 Feb 2001 06:21:44 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: don't want to let them enter & and = ...
Message-Id: <m1lmrizi87.fsf@halfdome.holdit.com>
>>>>> "emelin" == emelin <emelin@my-deja.com> writes:
emelin> I'm using the code below to fetch contents from a form. But if the user
emelin> enters & or = I encounter problems later on... things don't split
emelin> right...
You: "Doc, it hurts when I do this"
Doc: "Well, then don't do that!"
emelin> how do I check this before this code has split the contents??
Stop using "this code". Replace it with:
use CGI qw(import_names);
import_names('FORM');
Now, the form field for "fred" is now $FORM::fred. If it was a multi-value
item, you can use @FORM::fred as well.
Other options are available... see "perldoc CGI" for many more examples.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 07 Feb 2001 14:12:54 +0000
From: JMT <ccx138@coventry.ac.uk>
Subject: Re: Fastest way of left-padding a number?
Message-Id: <3A8157E6.27721622@coventry.ac.uk>
Jean-Louis Leroy wrote:
> John Tutchings <ccx138@coventry.ac.uk> writes:
>
> > Either you're using the wrong language or you algorithm is wrong and could
> > do with a rethink.
>
> Have you considered that I'm using the right language and the right
> algorithm and my thinking is fine, but I'm curious whether there's
> another (possibly faster) way than making sprintf parse format
> strings?
>
> > Explain the context and the need for speed.
>
> I use it in several places in Tangram to combine the per-class object
> id with the class id and thus produce the object id. See
> http://www.soundobjectlogic.com/tangram/doc/schema.html#global%20properties
>
> And btw the performance gain would probably be hidden by more
> expensive operations like talking to relational databases.
>
> So it's really a matter of curiosity, a quality (or fault) I'm not
> short of. Are you?
> --
> Jean-Louis Leroy
> http://users.skynet.be/jll
I was just curious to know why you would want to gain time over sprintf, that's
all. Like you say the gain would be lost by other actions.
A lot of code I have seen, including some in this newsgroup can be written in
more efficient ways. Often the data structure being used is to blame for the
slowness, things like loading items into an array and then grepping the array
several times for different values when an associative array would be quicker
etc. One I came across the other day on our system was something like:
opendir(DIR,$path);
@files = readdir(DIR);
@files = grep (!/^\.{1,2}$/, @files);
for $file (@files){
blah.
}
To remove . and .. from the readdir, this involves two reads of the array and it
would be better written with a next if statement inside the loop so you only
work through the array once.
I thought you may have had something like that that caused the slowness, that's
all.
No offence meant.
John
------------------------------
Date: 07 Feb 2001 16:33:03 +0100
From: Jean-Louis Leroy <jll63@easynet.be>
Subject: Re: Fastest way of left-padding a number?
Message-Id: <m3zofyik40.fsf@enterprise.starfleet>
JMT <ccx138@coventry.ac.uk> writes:
> I was just curious to know why you would want to gain time over
> sprintf, that's all
After re-reading my reply, I find it undeservedly dry. Please accept
my apologies.
> Like you say the gain would be lost by other actions.
Given the choice between two incantations that produce the same
result, and are more or less equally readable, I prefer to use the
faster one.
Also, Perl is such a large language...I thought there may be some new
trick to learn.
--
Jean-Louis Leroy
http://users.skynet.be/jll
------------------------------
Date: Wed, 07 Feb 2001 15:39:07 GMT
From: aramis1631@my-deja.com
Subject: Re: Hashes
Message-Id: <95rq6q$hd8$1@nnrp1.deja.com>
In article <f%4g6.1387$561.8850@eagle.america.net>,
garry@zvolve.com (Garry Williams) wrote:
> On Wed, 07 Feb 2001 02:52:27 GMT, aramis1631@my-deja.com
> <aramis1631@my-deja.com> wrote:
>
> >In article <95qbrr$cku$1@nnrp1.deja.com>,
> > bakor@my-deja.com wrote:
>
> [snip]
>
> >> %days_in_month=(Jan,31,Feb,28,Mar,31);
> >>
> >> $month=`date +%b`;
> >> print $month;
> >> print $days_in_month($month);
> >
> >It appears to me, that you have parens (), when you mean to use curly
> >braces {}.
>
> Nope.
>
> Braces will produce a reference to an anonymous hash.
I do not understand what you mean by this... he was attempting to
access a hash incorrectly.
> He's got it right, but he's not using strict. That's a Bad Thing.
strict would have pointed out his error, agreed.
>
> [snip]
>
> --
> Garry Williams
Er... Garry, you seem to know a lot; but, I do not understand your
response. Care to enlighten me? Ah, no doubt I was unclear and you
thought I was refering to the assignment of the hash in his first line?
I should have specified his print line, then.
The hash is %days_in_month
We access the hash value using a key thus,
$days_in_month{$month}
^^^ ^^^ Curly braces around the key, not parens
This does not create a reference to an anonymous hash, it returns the
value from the key=>value pair where $month is the key.
use strict; #definitely would have helped him because it would not have
compiled it would have told him that "Global symbol "$days_in_month"
requires explicit package name at..."
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 07 Feb 2001 08:03:20 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: hex to binary conversion ? Please help
Message-Id: <3A8155A8.D5273EE1@home.com>
Steven Smolinski wrote:
>
> tvn007@my-deja.com <tvn007@my-deja.com> wrote:
> > Hi ,
> >
> > I have hex number and would like to convert it to binanry.
> [...]
> This is pretty trivial, though, as long as you have perl 5.6.0:
>
> % perl -we 'printf "b%b\n", hex shift' BC
> b10111100
And if you don't have 5.6:
print dec2bin(hex('BC')), "\n";
sub dec2bin {
my $str = unpack('B32', pack('N', shift));
$str =~ s/^0+(?=\d)//; # strip leading zeroes
return $str
}
-mjc
------------------------------
Date: 07 Feb 2001 16:09:24 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: hex to binary conversion ? Please help
Message-Id: <cxcy9vio7h7.fsf@janus.uio.no>
Michael Carman <mjcarman@home.com> writes:
> And if you don't have 5.6:
>
> print dec2bin(hex('BC')), "\n";
>
> sub dec2bin {
> my $str = unpack('B32', pack('N', shift));
> $str =~ s/^0+(?=\d)//; # strip leading zeroes
> return $str
> }
This is "number 2 bin" or "int 2 bin", not "decimal 2 bin".
Peter
--
sub int2roman{@x=split//,sprintf'%04d',shift;@r=('','I','V','X','L','C','D'
,'M');@p=([],[1],[1,1],[1,1,1],[1,2],[2],[2,1],[2,1,1],[2,1,1,1],[1,3],[3])
;join'',@r[map($_+6,@{$p[$x[0]]}),map($_+4,@{$p[$x[1]]}),map($_+2,@{$p[$x[2
]]}),map($_+0,@{$p[$x[3]]})];}print "@{[map{int2roman($_)}@ARGV]}\n";#JAPH!
------------------------------
Date: Wed, 07 Feb 2001 15:02:28 GMT
From: philhibbs@my-deja.com
Subject: Re: how to remove item in the array?
Message-Id: <95ro1t$fgd$1@nnrp1.deja.com>
Hessu <qvyht@iobox.fi> wrote:
> problem is that checking trough whole array sucks all power
> and it's too slow way to do it anyway.
> can i do it with splice and how does this would work.
Can you clarify please - are you wanting to find and remove a specific
value from the array, or do you know the element number?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 07 Feb 2001 15:52:31 GMT
From: tanase_costin@my-deja.com
Subject: Re: how to remove item in the array?
Message-Id: <95rqvr$ia2$1@nnrp1.deja.com>
In article <3A813020.A88EB902@iobox.fi>,
Hessu <qvyht@iobox.fi> wrote:
> problem is that checking trough whole array sucks all power
> and it's too slow way to do it anyway.
> can i do it with splice and how does this would work.
>
> br,
> lerning perl
>
@newarray = grep { TESTBLOCK } @oldarray;
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 07 Feb 2001 15:42:09 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Linux does reclaim memory from perl
Message-Id: <t82r6hss3vod44@corp.supernews.com>
Jerome Abela <Jerome.Abela@free.fr> wrote:
> The Perl FAQ says:
>> Some operating systems (notably, FreeBSD) allegedly reclaim large chunks
>> of memory that is no longer used, but it doesn't appear to happen with
>> Perl (yet)
> I don't know about other operating systems, but on my Linux boxes, large
> memory chunks may be reclaimed, and it's easy to check:
I have a TCP server that serves many clients and Linux reclaims
memory that was used by all disconnected clients as soon as a new
one connects.
Luckily, large portions of the interpreter seem to live in shared
memory on a regular basis, which is also a very good thing.
Chris
--
Christopher E. Stith
It's not the U in UBE that pisses people off. It's the B.
-- Martien Verbruggen in clp.misc
------------------------------
Date: Wed, 07 Feb 2001 15:03:47 GMT
From: mgrime@my-deja.com
Subject: Re: Logfile pattern search & print
Message-Id: <95ro4c$fhj$1@nnrp1.deja.com>
In article <0m5g6.1397$561.9468@eagle.america.net>,
garry@zvolve.com (Garry Williams) wrote:
> On Wed, 07 Feb 2001 01:34:52 GMT, mgrime@my-deja.com
> <mgrime@my-deja.com> wrote:
> >
> >I have a log file where the first field is a date followed by the
time
> >and finally followed by some details like this:
> >
> >06Feb01 15:49:33 [6] OK:exec sendfsock
> >
> >Is there someone who would give me a hand with some simple code to
> >search for a pattern (preferably the whole line) and print that line
and
> >all the following lines? Is there maybe a one-liner?
>
> perl -ne 'next unless /06Feb01/../$^/;print'
>
> --
> Garry Williams
>
Garry,
Thanks for the response. I tested that bit of code and it is going to
work great. In my attempts at resolution, I was no where close. It
must be the ".." that tells perl to print the rest of the file - I'll
have to look that up. Thanks again for providing the learning
experience.
Mike
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 07 Feb 2001 14:58:40 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: Need advice: choosing between C++ CGI, Java servlets, or perl_mod CGI for simple high load web app.
Message-Id: <Aodg6.37369$49.6562986@news1.rdc2.pa.home.com>
"Craig Manley" <c.manley@spamsux.nl> wrote in message
news:3A7EE92C.3C37FE82@spamsux.nl...
> I've got a Perl CGI script (on Linux, Apache webserver) that per web
> request appends some short strings to about 20 files and returns a
> simple response. Nothing big deal, but we expect that once only and for
> a short period of about 15 minutes about 150000 requests will be made.
It seems like the real hurdle here is not the execution time, but jamming
together 170+ requests per second into one set of files. To avoid
contention, one thing you could do is create a small server process, that
opens the files for appending, and listens on a local socket for logging
requests
> Now I need to know what will most likely be faster for the webserver to
> execute:
> 1. My simple Perl script running under perl_mod.
> 2. A simple CGI executable made with C/C++.
> 3. A Java servlet (has threading as advantage but slower code execution
> as disadvantage).
>
> or......
>
> 4. choose NT and IIS and build an ISAPI DLL with C/C++/Delphi (threading
> as advantage - possibly slower OS as disadvantage).
>
> I hope I've provided enough details - it's really a simple script that
> does no heavy string processing or anything big deal, just logging.
If you already have a working CGI script, you could easily make it mod_perl
compatible. My gut feeling is that a mod_perl process that sends a single
logging packet to a listening daemon (perhaps on another machine?) should
work well.
--Ben Kennedy
------------------------------
Date: Wed, 07 Feb 2001 15:18:02 GMT
From: webbgroup <webbgroup@my-deja.com>
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <95rov0$g7e$1@nnrp1.deja.com>
> >Any suggestions??? Comments???
>
> #!/usr/bin/perl -l
> use warnings;
> use strict;
> use Socket;
>
> print "Invalid IP address." unless inet_aton(shift);
>
Whoah horsey, I am a newbie. I want to thank all the brainstorming
gurus that have responded. I checked out some of the other suggestions
about these different modules which is new for me. I didn't know about
the modules before, but this opens up a new world now.
I checked out the perl library like some of you guys said and I have
strict and Socket but not the warnings module.
Also, to throw another wrench in the machine is that I don't have root
access to the machine, so I couldn't install modules on the machine if
I wanted to. I am a just the lowly PERL scripter here at work.
Could I just use the Socket and the scrict modules??
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 07 Feb 2001 15:22:17 GMT
From: Sampo Huttunen <sh56649@uta.fi>
Subject: newbie: running script from a wrapper script in cron
Message-Id: <3A8167A6.3635B60C@uta.fi>
Hi!
I have a perl wrapper script that works fine if I run it from a shell,
but that fails when run from cron. This happens because the actual perl
script that does most of the work is executed in the end of the wrapper
script, but before it several smaller tasks must be done e.g. setting
environment variable and setting a configuration file to use. I use
system function to execute those pre-processing commands that are needed
for the main script. How can I execute the script from cron
"shell-like", so that it "remembers" the pre-processing instructions?
Thanks in advance,
Sampo
------------------------------
Date: Wed, 07 Feb 2001 14:42:18 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: Package question
Message-Id: <e9dg6.37251$49.6559955@news1.rdc2.pa.home.com>
"Kiel R Stirling" <taboo@comcen.com.au> wrote in message
news:3a7f5b67$1@nexus.comcen.com.au...
> while (@row=$sth->fetchrow_array())
> # Is there another way to return data?
> return @row;
> }
> }
> 1;
> ------------------------
> I just can't seem to find a way to streem the data back to my first while
loop.
I'm not quite sure what you are asking - are you trying to return multiple
rows from your subroutine? In that case, you need to create an array of
references - see "perldoc perllol". Y ou can't "stream" data back from a
subroutine (like the $sth fetchrow calls do) using typical mechanisms.
my @row;
my @all_rows;
while(@row = $sth->fetchrow_array()) {
push @all_rows, [ @row ];
}
return(@all_rows);
You may also try the DBI method that does it in one shot
my $data = $dbh->selectall_arrayref("YOUR SQL HERE");
Hope this helps
--Ben Kennedy
------------------------------
Date: Wed, 07 Feb 2001 14:54:07 GMT
From: Amos Shapira <amosshapira@my-deja.com>
Subject: perlcc fails on Windows 2000
Message-Id: <95rnia$evk$1@nnrp1.deja.com>
Hello,
My environment is as follows:
Windows 2000 Server on Intel Pentium
ActivePerl 5.6.0 build 623 (built Dec 15, 2000)
Microsoft Visual studio 6.0, when "cl" is invoked it says
"Version 12.00.8168" on the first output line.
I wrote a simple test program called "hello.pl" and which reads
as the following:
print "Hello, world\n";
exit 0;
Running it with "perl hello.pl" runs fine:
======================================================================
C:\Documents and Settings\amos>perl hello.pl
Hello, world
C:\Documents and Settings\amos>
======================================================================
But when I try to run "perlcc hello.pl" I get errors like:
======================================================================
C:\Documents and Settings\amos>perlcc hello.pl
------------------------------------------------------------------------
--------
Compiling hello.pl:
------------------------------------------------------------------------
--------
Making C(hello.pl.c) for hello.pl!
C:\installs\Perl\bin\Perl.exe -IC:/installs/Perl/lib -
IC:/installs/Perl/site/lib
-I. -MB::Stash -c hello.pl
C:\installs\Perl\bin\Perl.exe -IC:/installs/Perl/lib -
IC:/installs/Perl/site/lib
-I. -MO=C,-l2000,-umain,-uattributes,-uDB,-u<none>,-uWin32 hello.pl
The system cannot find the file specified.
ERROR: In generating code for hello.pl!
C:\Documents and Settings\amos>
======================================================================
I also copied hello.pl to "c:\Temp\hello.pl", cd'ed there and tried
again there, in case the spaces in the file's full path name confuse
perl, but got the same errors again.
So far I couldn't find anything about this in any forum or FAQ about
Perl. Any help would be greatly appreciated.
ActivePerl is installed under c:\installs\Perl and works fine with many
other home-brewed scripts.
BTW, I succeeded in compiling the script with perl2exe (from
http://www.perl2exe.com), but would rather try managing with the
"standard" tools.
Thanks,
--Amos Shapira
WebCollage
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 7 Feb 2001 15:20:43 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Radical readdir suggestion
Message-Id: <981558440.26257@itz.pp.sci.fi>
In article <slrn9829pp.vht.mgjv@martien.heliotrope.home>, Martien Verbruggen wrote:
>
>The file foo is also not part of the content of a directory. The name
>foo points to a file on the file systems somewhere. The names . and ..
>point to files on the file system somewhere. They are in that respect
>not special at all. They get automatically created by a mkdir, and they
>always point to directories, but that's pretty much where their
>specialness, as far as how they are part of a directory, ends.
Well, except for that fact that they create a loop of hard links.
The problem, as the OP stated, is that Unix filesystems can't make up
their minds whether to be trees or arbitrary directed graphs. On any
system which is fully the former, like that in AmigaOS, there are no
special entries in a directory, and every file and directory has one
and only one link pointing to it. On a system that is completely the
latter, of course, the concept of a parent directory is meaningless.
I wanted to check how File::Find deals with this, but apparently it
doesn't. There are other OS specific checks, but "." and ".." are
always skipped. So File::Find is broken on Macs, Amigas, etc.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"Regretfully I decided that the ability to turn _The Hobbit_ into a regency
romance wasn't a particularly useful skill after all."
-- Michelle Bottorff in rec.arts.sf.composition
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Wed, 7 Feb 2001 14:14:41 -0000
From: "Chris Burn" <chris.burn@bigfoot.com>
Subject: Re: regexp for splitting up file paths?
Message-Id: <95rl6m$1bcpr$1@news.wam.net>
excellent, thanks all.
"Philip Lees" <pjlees@ics.forthcomingevents.gr> wrote in message
news:3a815040.85409702@news.grnet.gr...
> On Wed, 7 Feb 2001 11:00:28 -0000, "Chris Burn"
> <chris.burn@bigfoot.com> wrote:
>
> >Hi, does anyone know of a regexp that will break up a file path into the
> >following components?
> >
> >so for filepath = /home/chris/test.0001.jpg
> >
> >path = /home/chris/
> >filehead = test.
> >filenumber = 0001
> >fileext = .jpg
>
> #!perl -w
>
> use strict;
>
> my $file = '/home/chris/test.0001.jpg';
>
> print "$file\n\n";
>
> if ( $file =~ /(.+\/)(.+?)(\d+)(\..+)$/ ){
> print "path = $1\nfilehead = $2\nfilenumber = $3\nfileext = $4\n";
> }else{
> print "Doesn't match.";
> }
>
> The above works if filehead never contains any numeric characters and
> filenumber always contains only numeric characters. If either of those
> conditions may not be satisfied, _but_ filehead always ends with a
> '.', you can use this instead.
>
> if ( $file =~ /(.+\/)(.+\.)(.+)(\..+)$/ ){
>
> Both work for your example. Tweak as necessary.
>
> This may give you some ideas, anyway.
>
> See perlre for more.
>
> Phil
> --
> Philip Lees
> ICS-FORTH, Heraklion, Crete, Greece
> Ignore coming events if you wish to send me e-mail
> 'The aim of high technology should be to simplify, not complicate' - Hans
Christian von Baeyer
------------------------------
Date: Wed, 7 Feb 2001 15:30:35 -0000
From: "Peter John Cameron" <peterca@ukgateway.net>
Subject: waiting for a file to be created
Message-Id: <95rppj$ggf$1@lure.pipex.net>
I have a perl script that's called from a Java application. The script uses
an open call to start a statistical application that is fed input from Java
via the perl script. The complicating factor is that the stats app creates a
file which the perl script is then expecting to process. However, the perl
code is proceeding to process the as yet non-existant file. It all works if
I pause the script by putting a for loop after the open's close. This gives
time for the stats app to finish creating the file (note, the file is
created internally by the stats app and not by redirection). But a for loop
is a messy solution, and not platform independent: a 1GHz computer may
require a large loop counter for instance. I thought the close would be
enough, but it obviously isn't.
In another perl script used by the Java, there's a system call to invoke
another app that produces needed files. This works fine, but in this
situation the app called by system doesn't need any input.
It's probably not the best architected software that I'm dealing with, but
it's what I've been given.
Any thoughts appreciated,
Cheers,
Peter
------------------------------
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 V10 Issue 232
**************************************