[18791] in Perl-Users-Digest
Perl-Users Digest, Issue: 959 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 22 14:10:46 2001
Date: Tue, 22 May 2001 11:10:26 -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: <990555025-v10-i959@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 22 May 2001 Volume: 10 Number: 959
Today's topics:
library Files in Perl <replytogroup@nowhere.com>
Re: library Files in Perl <todd@designsouth.net>
Re: library Files in Perl (Martien Verbruggen)
Re: library Files in Perl nobull@mail.com
Re: linux: check whether an external program is running <bernie@fantasyfarm.com>
Re: linux: check whether an external program is running <chok@ece.gatech.edu>
Re: linux: check whether an external program is running <chok@ece.gatech.edu>
Re: module for combinatorics? (partitions etc) <EUSWMCL@am1.ericsson.se>
Re: module for combinatorics? (partitions etc) (Mark Jason Dominus)
Re: module for combinatorics? (partitions etc) <EUSWMCL@am1.ericsson.se>
Re: of the TWO perl-debugging books, which best? <uri@sysarch.com>
Re: passing subroutine as parameter to a function (Mark Jason Dominus)
Re: Perl 5.6.1 on SCO5.0.4 - Problem with dynamic loadi (Andy Dougherty)
Perl and Informix.VVP <vprasad@americasm01.nt.com>
push onto trinary conditional operator? <prlawrence@lehigh.edu>
Re: push onto trinary conditional operator? <uri@sysarch.com>
Re: push onto trinary conditional operator? (Greg Bacon)
Re: push onto trinary conditional operator? <uri@sysarch.com>
Redirecting STDERR to sendmail <john@princenaseem.com>
Re: Redirecting STDERR to sendmail nobull@mail.com
references trouble <smrtalec@nospam.earthlink.net>
Re: RegEx Problem, Please?! <ren@tivoli.com>
Re: Stringformation <pne-news-20010522@newton.digitalspace.net>
Re: Stringformation <peb@bms.umist.ac.uk>
Time validation <daryl.l.shute@boeing.com>
Re: Time validation <kistler@gmx.net>
Re: Time validation <godzilla@stomp.stomp.tokyo>
what does this mean? <jwatson@Mysticglow.com>
Re: what does this mean? (Mark Jason Dominus)
Re: what does this mean? <bart.lateur@skynet.be>
Re: what does this mean? <jwatson@Mysticglow.com>
win32 ExitProcess makes stdout disappear <frank.brown@ci.seattle.wa.us>
wwwboard.pl - Taint and Use Strict (Jill)
Re: wwwboard.pl - Taint and Use Strict <godzilla@stomp.stomp.tokyo>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 May 2001 16:01:30 +0100
From: "st" <replytogroup@nowhere.com>
Subject: library Files in Perl
Message-Id: <9edv12$h39$1@news8.svr.pol.co.uk>
Is it possible to call a library file in Perl.
The library file would contain commonly used sub-routines
How it the library file called if possible ?
Thanks for any help
Neil
------------------------------
Date: Tue, 22 May 2001 15:19:22 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: library Files in Perl
Message-Id: <_rvO6.56299$I5.12277559@news1.rdc1.tn.home.com>
"st" <replytogroup@nowhere.com> wrote in message
news:9edv12$h39$1@news8.svr.pol.co.uk...
> Is it possible to call a library file in Perl.
>
> The library file would contain commonly used sub-routines
>
> How it the library file called if possible ?
>
> Thanks for any help
>
> Neil
>
>
Yeah, just write it, people usually call them "whatever.pl", and put this
line in your script:
require 'whatever.pl';
Make sure perl can find it in @INC, of course, and put a '1;' as the last
line so it returns true, and there you go
------------------------------
Date: Wed, 23 May 2001 01:53:02 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: library Files in Perl
Message-Id: <slrn9gl2qu.v5e.mgjv@martien.heliotrope.home>
On Tue, 22 May 2001 16:01:30 +0100,
st <replytogroup@nowhere.com> wrote:
> Is it possible to call a library file in Perl.
I'm not sure the librarian would approve.
> The library file would contain commonly used sub-routines
>
> How it the library file called if possible ?
Perl libraries are most commonly files. They often have the extension
.pl, and are included in your program with the require statement.
Nowadays people tend to write modules more often than the more
traditional libraries. Modules have the extension .pm, and most commonly
contain subroutines and possibly variables that all belong in one
package, or name space.
You probably want to read up on a few things. Read the perlfunc
documentation, the entries for do, require and use. Also read the
perlmod and perlmodlib documentation. Use the appropriate[1] command to
read these pages.
Also read the perl documentation itself. it's got loads of references to
other documentaiton to read. If you've got the money, get /Programming
Perl/, the Camel.
$ man perl
Martien
[1] man or perldoc on Unix, perldoc or HTML pages for ActiveState Perl
on Win, Shuck on Mac.
--
Martien Verbruggen |
Interactive Media Division | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: 22 May 2001 18:28:02 +0100
From: nobull@mail.com
Subject: Re: library Files in Perl
Message-Id: <u9lmnp8fa5.fsf@wcl-l.bham.ac.uk>
"Todd Smith" <todd@designsouth.net> writes:
> "st" <replytogroup@nowhere.com> wrote in message
> news:9edv12$h39$1@news8.svr.pol.co.uk...
> >
> > The library file would contain commonly used sub-routines
> >
> > How it the library file called if possible ?
>
> Yeah, just write it, people usually call them "whatever.pl", and put this
> line in your script:
>
> require 'whatever.pl';
I would dispute the sweeping assertion that "people usually" use old
Perl4-style libraries rather than Perl5-style libraries (aka Exporter
modules).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 22 May 2001 09:35:50 -0400
From: Bernard Cosell <bernie@fantasyfarm.com>
Subject: Re: linux: check whether an external program is running
Message-Id: <0bqkgt82effkeoel57i7hcfcu84jbj89cj@4ax.com>
On Mon, 21 May 2001 19:51:13 -0400, ChokSheak Lau
<chok@ece.gatech.edu> wrote:
} i can't find an answer to this anywhere. basically, I'm trying to find
} out from a Perl script whether a certain program is running or not,
} without the PID.... if you have a cleaner, leaner and faster way to do that,
} pls let me know. any help is appreciated.
Use /proc. You should be able to find what you want in
/proc/NNNNN/cmdline. What you need is something like:
opendir(P, "/proc") or TROUBLE ;
while (defined($_ = readdir P))
{
next if /\D/ ;
next unless `cat /proc/$_/cmdline` =~ /^COMMANDYOUWANT\b/ ;
[ there's your process and $_ is its PID.]
}
closedir P ;
/Bernie\
[NB : above code is off the cuff and not test, YMMV...:o) /b\ ]
------------------------------
Date: Tue, 22 May 2001 10:55:23 -0400
From: ChokSheak Lau <chok@ece.gatech.edu>
Subject: Re: linux: check whether an external program is running
Message-Id: <3B0A7DDB.CD92A55D@ece.gatech.edu>
thanks dude, that was something i couldn't have figured out.
chok :-)
Bernard Cosell wrote:
> On Mon, 21 May 2001 19:51:13 -0400, ChokSheak Lau
> <chok@ece.gatech.edu> wrote:
>
> } i can't find an answer to this anywhere. basically, I'm trying to find
> } out from a Perl script whether a certain program is running or not,
> } without the PID.... if you have a cleaner, leaner and faster way to do that,
> } pls let me know. any help is appreciated.
>
> Use /proc. You should be able to find what you want in
> /proc/NNNNN/cmdline. What you need is something like:
>
> opendir(P, "/proc") or TROUBLE ;
> while (defined($_ = readdir P))
> {
> next if /\D/ ;
> next unless `cat /proc/$_/cmdline` =~ /^COMMANDYOUWANT\b/ ;
> [ there's your process and $_ is its PID.]
> }
> closedir P ;
>
> /Bernie\
>
> [NB : above code is off the cuff and not test, YMMV...:o) /b\ ]
------------------------------
Date: Tue, 22 May 2001 11:50:01 -0400
From: ChokSheak Lau <chok@ece.gatech.edu>
Subject: Re: linux: check whether an external program is running
Message-Id: <3B0A8AA9.F0DE436B@ece.gatech.edu>
anyway, getting rid of the `cat` and using "open" would speed up the
code tremendously. and yes, your method is about 30 times faster than
the ps | grep thing. using `cat` would make it abt 10 times slower.
chok
Bernard Cosell wrote:
> On Mon, 21 May 2001 19:51:13 -0400, ChokSheak Lau
> <chok@ece.gatech.edu> wrote:
>
> } i can't find an answer to this anywhere. basically, I'm trying to find
> } out from a Perl script whether a certain program is running or not,
> } without the PID.... if you have a cleaner, leaner and faster way to do that,
> } pls let me know. any help is appreciated.
>
> Use /proc. You should be able to find what you want in
> /proc/NNNNN/cmdline. What you need is something like:
>
> opendir(P, "/proc") or TROUBLE ;
> while (defined($_ = readdir P))
> {
> next if /\D/ ;
> next unless `cat /proc/$_/cmdline` =~ /^COMMANDYOUWANT\b/ ;
> [ there's your process and $_ is its PID.]
> }
> closedir P ;
>
> /Bernie\
>
> [NB : above code is off the cuff and not test, YMMV...:o) /b\ ]
------------------------------
Date: Tue, 22 May 2001 09:03:35 -0400
From: William Cardwell <EUSWMCL@am1.ericsson.se>
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <3B0A63A7.8A90B8BE@am1.ericsson.se>
Mark Jason Dominus wrote:
>
> If you don't care, probably the easiest thing to do is to generate the
> first n-1 integers totally at random, and then just compute
> x - (i1 + i2 + ...) and let that be the n'th integer.
>
> Nobody would bother writing a module for this because it would be
> about four lines long.
>
But let's say he wants whole numbers. Techniques I have played with tend
toward over-use of 0 when you the random numbers must have a ceiling on
their sum. Do you know a way to do it that would generate random results
(at least as random as rand function itself, let's say)?
------------------------------
Date: Tue, 22 May 2001 13:30:26 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <3b0a69e4.2fa6$4b@news.op.net>
In article <3B0A63A7.8A90B8BE@am1.ericsson.se>,
William Cardwell <EUSWMCL@am1.ericsson.se> wrote:
>Techniques I have played with tend
>toward over-use of 0
As I said, without some sort of clear statement about what sort of
distribution the original poster wants, we have no way to judge
'over-use of 0'.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Tue, 22 May 2001 12:17:25 -0400
From: William Cardwell <EUSWMCL@am1.ericsson.se>
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <3B0A9115.84B7A44D@am1.ericsson.se>
Mark Jason Dominus wrote:
>
> In article <3B0A63A7.8A90B8BE@am1.ericsson.se>,
> William Cardwell <EUSWMCL@am1.ericsson.se> wrote:
> >Techniques I have played with tend
> >toward over-use of 0
>
> As I said, without some sort of clear statement about what sort of
> distribution the original poster wants, we have no way to judge
> 'over-use of 0'.
>
In your 4 lines or so, for his case of 5 [I am proposing] whole numbers
totaling 18, how will you pick the bounds of the 1st random number...
the 2nd...etc?
------------------------------
Date: Tue, 22 May 2001 14:46:39 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: of the TWO perl-debugging books, which best?
Message-Id: <x7ae45786p.fsf@home.sysarch.com>
>>>>> "DC" == David Combs <dkcombs@panix.com> writes:
DC> There are TWO perl debugging books:
DC> . "Debugging Perl" by Martin Brown (Osbourne/McGraw Hill)
DC> . CSBOOK: Why, yes: "Perl Debugged," by Peter Scott and Ed
DC> Wright. Addison-Wesley, 2001.
DC> Which of the two is the best?
i have not seen the brown book but i just read perl debugged over the
weekend.
i like it a lot. it brings up a wide range of buggy subjects and shows
the reader how to be aware of them and how to tackle them. its goal is
not just to show you how to debug your program but how to prevent bugs
from happening. i like its writing style as well, informative but
casual. it also has a set of key points and ideas (perls of wisdom)
that are specially marked and there is a pullout card listing them all
inside the cover. one of the authors is a well known perl trainer and
many of the bug issues he covers arose in his classes. that is great as
it shows how people actually live and die with perl. it has a home page
at http://www.perldebugged.com/perldebugged/index.html but i don't see
any sample chapters.
brown has written a couple of other perl books but isn't involved in the
perl community at all AFAIK. this is a weakness with any perl author
IMO. not tapping the community for tech review, ideas, help, etc. does
not make me feel confident about a perl author. some folks have liked
his other books so i don't expect this to be a total loss. its page is
at http://www.osborne.com/programming_webdev/0072126760/0072126760.shtml
and there is a sample chapter which is the introduction. at first glance
it seems to be well written.
other than that, you should go to a good computer bookstore and browse
them both.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Tue, 22 May 2001 13:35:43 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: passing subroutine as parameter to a function
Message-Id: <3b0a6b2e.2fc4$293@news.op.net>
In article <9eckiq$1if$1@netnews.upenn.edu>,
Rosa Qian <rqian_2000@yahoo.com> wrote:
>Does anyone know how to pass a subroutine as a parameter to a function,
>where the subroutine also takes in paramters.
If File::Find had been designed better, this would be easy.
Probably the best solution is to define an anonymous function which
calls processTemplate with the correct arguments, and use the
anonymous function as the 'wanted' parameter:
{ my ($login, $logout) = ...
...
my $stub = sub { processTemplate($login, $logout, @_) };
...
find({wanted => $stub, no_chdir => 1}, './general/templates');
}
If you do it this way, the $stub will always pass the current values
of $login and $logout, even if those values change.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Tue, 22 May 2001 17:56:21 -0000
From: doughera@maxwell.phys.lafayette.edu (Andy Dougherty)
Subject: Re: Perl 5.6.1 on SCO5.0.4 - Problem with dynamic loading
Message-Id: <slrn9gla4k.2ue.doughera@maxwell.phys.lafayette.edu>
In article <9e5dmu$s3a$1@reader-00.news.insnet.cw.net>, Paul Mahoney wrote:
>I've download and build perl 5.6.1 on my SCO 5.0.4 system and compiled it
>using gcc 2.95.2 (from sco skunkware). I checked the hints/sco.sh file for
>instructions and run the following:
> sh Configure -de -Dcc=gcc
> make
> make test
> make install
>
>This went well. Only one test failed (lib/bigfltpm) which didn't worry me.
If 'make test' went ok, then dynamic loading is generally working ok.
>So I then tried to rebuild and install my favourite modules...
>
>Running "make test" I keep getting:
> Can't Load '/usr/local/lib/perl5/5.6.1/i386-sco/auto/IO/IO.so' for module
>IO:
> dynamic linker: /usr/local/bin/perl: relocation error: symbol not found:
>fsync
> at /usr/local/lib/perl5/5.6.1/i386-sco/XSLoader.pm line 75.
> at /usr/local/lib/perl5/5.6.1/i386-sco/IO.pm line 9.
Hmm. It appears you've found a hole in the test suite.
Please check the following two things:
1. Does your system actually have fsync() ?
2. Does perl know about it? Try perl -V:d_fsync
>I really need a dynamic loading version. Can anybody help?
You seem to have one, if you passed 'make test'. It looks like it's
just the fsync() function that's in trouble.
If your system doesn't have fsync(), I'll try to track down why IO's
failing in that case.
--
Andy Dougherty doughera@lafayette.edu
Dept. of Physics
Lafayette College, Easton PA 18042
------------------------------
Date: Tue, 22 May 2001 11:50:37 -0400
From: "Prasad, Victor [FITZ:K500:EXCH]" <vprasad@americasm01.nt.com>
Subject: Perl and Informix.VVP
Message-Id: <3B0A8ACD.40C26032@americasm01.nt.com>
Hello,
I am using a PERL script to run Unix script that gets data from a
Informix database.
Now I need to check an Informix table to verify data from PERL.
I am not sure how to do this.
Where should I get started?
Thanks,
V
------------------------------
Date: Tue, 22 May 2001 10:53:01 -0400
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: push onto trinary conditional operator?
Message-Id: <9edugd$h76@fidoii.CC.Lehigh.EDU>
Camel 3.0 states you can assign to the conditional operator if both
the 2nd and 3rd args are legal lvalues and both are scalars or lists.
Thus:
DB<1> ( (0) ? @a : @b ) = (1)
DB<2> x @b
0 1
So why doesn't this work:
DB<3> push ( (0) ? @a : @b ), 1
DB<4> x @b
empty array
Thanks!
Phil R. Lawrence
------------------------------
Date: Tue, 22 May 2001 15:27:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: push onto trinary conditional operator?
Message-Id: <x7zoc55rqq.fsf@home.sysarch.com>
>>>>> "PRL" == Phil R Lawrence <prlawrence@lehigh.edu> writes:
PRL> So why doesn't this work:
PRL> DB<3> push ( (0) ? @a : @b ), 1
^ ^
that looks like a func, so that is all push sees. either wrap that and
the ,1 in () or put a + in front of the () to make it into an argument.
push ( ( (0) ? @a : @b ), 1 )
push +( (0) ? @a : @b ), 1
another solution is to use array refs:
push @{ (0) ? \@a : \@b}, 1
that doesn't have the paren issues that your code has.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Tue, 22 May 2001 15:28:15 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: push onto trinary conditional operator?
Message-Id: <tgl1cf78060qbc@corp.supernews.com>
In article <9edugd$h76@fidoii.CC.Lehigh.EDU>,
Phil R Lawrence <prlawrence@lehigh.edu> wrote:
: Thus:
: DB<1> ( (0) ? @a : @b ) = (1)
:
: DB<2> x @b
: 0 1
:
: So why doesn't this work:
: DB<3> push ( (0) ? @a : @b ), 1
:
: DB<4> x @b
: empty array
I believe pre-5.6 perls understood this. You can do the same with
the following ugly workaround:
push @{ $condition ? \@a : \@b }, @items;
Greg
--
Isn't it curious how ``page'' has become a colloquial term for the word
``document'' in hypertext, in a medium that does not have pages anymore?
Do we reuse words as soon as they are freed up by technology? Do we reuse
those of whose destruction we can't bear to be reminded? -- Jutta Degener
------------------------------
Date: Tue, 22 May 2001 15:42:38 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: push onto trinary conditional operator?
Message-Id: <x7vgmt5r0x.fsf@home.sysarch.com>
>>>>> "RG" == Rafael Garcia-Suarez <rgarciasuarez@free.fr> writes:
RG> } So why doesn't this work:
RG> } DB<3> push ( (0) ? @a : @b ), 1
RG> push does not assign to its array argument. It modifies the array
RG> contents.
and ?: will return an lvalue array. his problem was wrong paren
grouping. see my other post on this.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Tue, 22 May 2001 18:01:24 +0100
From: "JohnShep" <john@princenaseem.com>
Subject: Redirecting STDERR to sendmail
Message-Id: <lYwO6.4490$26.46416@NewsReader>
Hi,
I have ftp access to my cron directory but no access to the logs. I want to
email any errors to myself and so far I've come up with the structure below
which I am afraid is as much use as a chocolate teapot. Can someone point me
in the right direction ?
Thanks, John
#!/usr/bin/perl -w
$MAIL = '/usr/sbin/sendmail';
$MAIL_FLAGS = '-t -oi';
$WEBMASTER = 'me@myemail.com';
sub BEGIN {
open (STDOUT,"| $MAIL $MAIL_FLAGS") || die "mail: $!";
select STDOUT; $| = 1;
open (STDERR,">&STDOUT");
my $date = localtime();
print <<END;
To: $WEBMASTER
From: Script Monitor <nobody>
Subject: Script STDERR & STDOUT
END
;
}
# Script goes here
sub END {
close STDERR;
close STDOUT;
}
------------------------------
Date: 22 May 2001 18:41:24 +0100
From: nobull@mail.com
Subject: Re: Redirecting STDERR to sendmail
Message-Id: <u9itit8env.fsf@wcl-l.bham.ac.uk>
"JohnShep" <john@princenaseem.com> writes:
> $MAIL = '/usr/sbin/sendmail';
> $MAIL_FLAGS = '-t -oi';
> $WEBMASTER = 'me@myemail.com';
>
> sub BEGIN {
>
> open (STDOUT,"| $MAIL $MAIL_FLAGS") || die "mail: $!";
> select STDOUT; $| = 1;
> open (STDERR,">&STDOUT");
>
> my $date = localtime();
> print <<END;
> To: $WEBMASTER
> From: Script Monitor <nobody>
> Subject: Script STDERR & STDOUT
> END
> ;
> }
You should put the assignments inside a BEGIN block too that the
variabled are assigned _before_ they are used.
You probably should unbuffer STDERR too.
BTW: select STDOUT is redundant.
BTW: More use of lexical variables would be a good idea.
BTW: You never use $date.
BTW: The token "sub" in front of BEGIN is optional, and usually omitted.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 22 May 2001 16:53:32 GMT
From: "R" <smrtalec@nospam.earthlink.net>
Subject: references trouble
Message-Id: <gQwO6.10084$9D5.910294@newsread2.prod.itd.earthlink.net>
I'm working on a small app, which uses, hash references. I have been
following the examples in the advanced perl programming book. (o'rielly)
onfortunatly I dont have them today. when I try to test my hash reference I
get an error. what am I doing wrong
Here is a part of the initial program which calls the references.
my $radd_name = add_name(); # subroutine populates a local hash and returns
a ref.
my @job_info=($radd_name,$radd_address);
$user{$user_number}=\@job_info;
################################# test cycle
print "test cycle\n";
foreach $key (keys (%user)) {
print "key:$key -- value:$user{$key}\n";
}
# print $user{$user_number}->[1]->{first};
#################################
The test cycle print the following
test cycle
key:00-01-01 -- value:ARRAY(0x814837c)
here is a part of the add_name subroutine.
the below actually shows my test to make sure the hash is populated which it
is.
it then returns a reference. the rest of the routine is just inputting
info.
#################################
print "test cycle\n";
foreach $key (keys (%name)) {
print "key:$key -- value:$name{$key}\n";
}
#################################
return (\%name);
------------------------------
Date: 22 May 2001 09:55:07 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: RegEx Problem, Please?!
Message-Id: <m3r8xhcu2c.fsf@dhcp9-172.support.tivoli.com>
On Tue, 22 May 2001, peb@bms.umist.ac.uk wrote:
> Ren Maddox wrote:
>
[snip]
>> Based on what you've given, all we can do is look for syntax errors
>> or obvious logical errors. We're going to need more than that to
>> go on.
>
> We do get a hint as to what the OP wants out of the code
>
>>I want to get specific part out of a document.
> <snip code>
>
> we can then assume that the OP is reading a file and wants to parse
> out a small part of it. Hopefully that part is marked up in some
> unique way.
>
> I may be way off the mark but that's my interpretation of the
> situation.
Yeah, I started to go on and make that assumption but decided that
there was just too much ambiguity. The part that really threw me was
the reference to the end marker being before the body.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Tue, 22 May 2001 15:44:48 +0200
From: Philip Newton <pne-news-20010522@newton.digitalspace.net>
Subject: Re: Stringformation
Message-Id: <87rkgtgjjhj9u4ulhomvh24kn0r6g180do@4ax.com>
On Tue, 22 May 2001 12:32:49 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:
> Furthermore: we have a web server in the US for a European audience.
> "use locale;" will most likely not do the right thing, even if it is
> doing what it is supposed to do.
That's what POSIX::setlocale is for, isn't it? So you should be able to
have a web server in US running an OS developed in China with a default
environment appropriate for Swahili speakers, and still use something
like setlocale( LC_ALL, 'la_VA' ) and get numbers, dates, etc., in a
format appropriate for Latin speakers in the Vatican City.
Note: I have no experience with locales myself.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Tue, 22 May 2001 15:11:38 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Stringformation
Message-Id: <3B0A739A.B4845D6D@bms.umist.ac.uk>
Rene Scheibe wrote:
>
> Can someone explain me this code a little bit, please.
>
> > # from Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
> > sub commify {
> > my $input = shift;
grab the input (if called like commify($number)).
> > $input = reverse $input;
reverse it, so that 5456.7888999 becomes 9998887.5645
> > $input =~ s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
now look through the string for instances of 3 digits that are followed
by another digit but don't have a decimal point forward of them. When
you find an instance replace it with itself followed by a comma.
so 9998887.5645 would become 998887.564,5
> > return scalar reverse $input;
> > }
reverse the input again (so that it is in the correct orientation) and
return it.
HTH
Paul
------------------------------
Date: Tue, 22 May 2001 14:53:57 GMT
From: "Daryl Shute" <daryl.l.shute@boeing.com>
Subject: Time validation
Message-Id: <GDqs1x.3zI@news.boeing.com>
I have a form that needs to be submitted only during the hours of 0600 -
1515 Monday through Friday, and not on Holidays. If the time or date is not
in this time frame I need to send the user to another WebPage, otherwise
allowing the user to continue on with the form submission.
Any help would be greatly appreciated.
Thanks in advance.
Daryl Shute
Linux, because life's too short for a buggy OS.
------------------------------
Date: Tue, 22 May 2001 18:28:38 +0200
From: Per Kistler <kistler@gmx.net>
To: Daryl Shute <daryl.l.shute@boeing.com>
Subject: Re: Time validation
Message-Id: <3B0A93B6.2D86E340@gmx.net>
Daryl Shute wrote:
> I have a form that needs to be submitted only during the hours of 0600 -
> 1515 Monday through Friday, and not on Holidays.
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
Then some if()s for weekday and daytime.
Per Kistler.
------------------------------
Date: Tue, 22 May 2001 09:37:39 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Time validation
Message-Id: <3B0A95D3.CD1A6F02@stomp.stomp.tokyo>
Daryl Shute wrote:
(snipped)
> I have a form that needs to be submitted only during the hours of 0600 -
> 1515 Monday through Friday, and not on Holidays. If the time or date is not
> in this time frame I need to send the user to another WebPage, otherwise
> allowing the user to continue on with the form submission.
This is highly illogical and is most contrary to this concept of
the internet being "open for business" around the clock, even if
an intranet rather than the internet.
Clearly your system is running twenty-four hours a day with this
form always being available, as indicated by your implied parameters.
A form action requires no human intervention. Your form action on
this system is available, so is your associated script and any
required data base along with disk storage ability for data
submission, all indicated by your ability to redirect. There
exists no logical reason to disallow use of a form action based
upon a temporal basis.
Should you respond with logic of "Human intervention is required."
My response will be, "Why?"
Ignoring your lack of logic, you have stated no parameters. You
have not stated if this is local time or time relative to Greenwich
Mean Time. There is no indication if you are in a time zone affected
by Daylight Savings Time. Most important, you have provided zero
parameters regarding what days constitute a holiday.
Post your code you have written thus far to address these issues.
Godzilla!
------------------------------
Date: Tue, 22 May 2001 08:14:09 -0500
From: John Watson <jwatson@Mysticglow.com>
Subject: what does this mean?
Message-Id: <3B0A6621.5D671594@Mysticglow.com>
I ran into this in an if expression and was wondering what !~ means?
Thanks.
------------------------------
Date: Tue, 22 May 2001 13:31:40 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: what does this mean?
Message-Id: <3b0a6a3c.2fb3$2d7@news.op.net>
In article <3B0A6621.5D671594@Mysticglow.com>,
John Watson <jwatson@Mysticglow.com> wrote:
>I ran into this in an if expression and was wondering what !~ means?
Good question. I don't think anyone here knows, but it seems like the
sort of thing that might be explained in the manual.
Try doing a web search for 'perlop' and see what you come up with.
If you find anything out, please let us know.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Tue, 22 May 2001 13:55:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: what does this mean?
Message-Id: <f0skgtc499ce90chm2294733uahiotq3rh@4ax.com>
John Watson wrote:
>I ran into this in an if expression and was wondering what !~ means?
It's a combination of ! (not) and =~.
$a !~ /$re/
is pretty much the same as
!($a =~ /$re/)
--
Bart.
------------------------------
Date: Tue, 22 May 2001 09:17:19 -0500
From: John Watson <jwatson@Mysticglow.com>
Subject: Re: what does this mean?
Message-Id: <3B0A74EF.470ADD04@Mysticglow.com>
Ugh, I thought ! was not but this shorthand is murder.
Thanks.
Bart Lateur wrote:
>
> John Watson wrote:
>
> >I ran into this in an if expression and was wondering what !~ means?
>
> It's a combination of ! (not) and =~.
>
> $a !~ /$re/
>
> is pretty much the same as
>
> !($a =~ /$re/)
>
> --
> Bart.
------------------------------
Date: Tue, 22 May 2001 15:32:42 GMT
From: "frank brown" <frank.brown@ci.seattle.wa.us>
Subject: win32 ExitProcess makes stdout disappear
Message-Id: <uEvO6.253$5Z.49775@news-west.eli.net>
I recently discovered that capturing shell output via backticks in a perl
script
fails on W2K when executing a Win32 .exe file which exits via ExitProcess.
Replacing ExitProcess(0) with exit(0) in the called .exe fixes the problem.
What's up with this? A brief search thru MSDN turns up no clues.
Frank Brown
Seattle Fire Dept.
http://www.halcyon.com/frog/
------------------------------
Date: 22 May 2001 09:23:01 -0700
From: jmjlampert@aol.com (Jill)
Subject: wwwboard.pl - Taint and Use Strict
Message-Id: <9287c79.0105220823.5e3d9227@posting.google.com>
Hi,
I am a newby.
I have modified wwwboard.pl from Matts Script Archive for use on my
website. Now I find that I am required to use the "-T" (Taint) switch
and "Use Strict" pragma for security reasons.
I have read the relevant perl documentation and references to both
these things in several books, but am unable to put the instructions
for untainting and declaring variables into practice.
Has anyone out there already modified wwwboard.pl so that it will pass
the Taint switch and Use Strict ? If so, is there any way I could get
hold of that modified script ?
Any suggestions much appreciated.
Jill
------------------------------
Date: Tue, 22 May 2001 09:50:45 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: wwwboard.pl - Taint and Use Strict
Message-Id: <3B0A98E5.732E5CB0@stomp.stomp.tokyo>
Jill wrote:
(snippage)
> I have modified wwwboard.pl from Matts Script Archive for use on my
> website. Now I find that I am required to use the "-T" (Taint) switch
> and "Use Strict" pragma for security reasons.
Neither Taint nor Strict are required. There is nothing about
perl core which "requires" you to use these pragma. Use of Taint
is a very poor approach to effective and efficient script security.
Use of strict is unrelated to security.
> I have read the relevant perl documentation and references to both
> these things in several books, but am unable to put the instructions
> for untainting and declaring variables into practice.
You indicate knowledge of Strict being related to declaring variables.
Why have you previously included Strict as a security concern?
A clear logical approach would be to research and read about how
to use these features via resources other than Perl documentation
and those books which are available to you.
Do your homework.
Godzilla!
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 959
**************************************