[9694] in Perl-Users-Digest
Perl-Users Digest, Issue: 3288 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 29 16:07:19 1998
Date: Wed, 29 Jul 98 13:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 29 Jul 1998 Volume: 8 Number: 3288
Today's topics:
Re: Can't figure out how to remove newlines <melinda@acm.org>
Re: Code for deciding week number? (Fred Hurtubise)
Re: Dereferencing Hashes and Arrays (Mark-Jason Dominus)
Finding online users <mabee@students.uiuc.edu>
Re: Glob problem (Daniel)
Re: hiding user input <lance@nospam.net-school.com>
Re: hiding user input (Fred Hurtubise)
Re: I want to separate my Perl from my HTML (William Wueppelmann)
Re: Interesting Question needs Quick Answer <shadolin@cableinet.co.uk>
Re: Interesting Question needs Quick Answer <shadolin@cableinet.co.uk>
Re: Interesting Question needs Quick Answer <shadolin@cableinet.co.uk>
Re: Is it possible (Andrew M. Langmead)
loggin out of CGI authenticated state (Hu Liang)
Re: Misleading documentation (Joe McMahon)
open IN, "file " or die <= it dies! mickghazey@my-dejanews.com
Re: perl as pseudocode <ghira@mistral.co.uk>
Perl variable types problems <melkor@valimar.middle.earth>
Re: Perl5.005: any good Thread::kill workaround ideas? (Nem W Schlecht)
removing accented characters from a string ultrasparc@my-dejanews.com
Sending out eMails in predefined intervals ? c20xe@my-dejanews.com
Re: Submit only Once (William Wueppelmann)
Re: Submit only Once (William Wueppelmann)
sytem( ) calls in CGI scripts (Brian Day)
Re: sytem( ) calls in CGI scripts (Mark-Jason Dominus)
Re: This is an easy question! (Pete Ratzlaff)
Re: Y2K problem in PERL with localtime() (John Stanley)
Re: Y2K problem in PERL with localtime() (John Stanley)
Re: Y2K problem in PERL with localtime() (John Stanley)
Re: Y2K problem in PERL with localtime() (Matt Knecht)
Re: Y2K problem in PERL with localtime() (Michael J Gebis)
Year 2000 <jsteorts@csc.com>
Re: Year 2000 (Mark-Jason Dominus)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 29 Jul 1998 18:06:52 GMT
From: "Quinn,M" <melinda@acm.org>
Subject: Re: Can't figure out how to remove newlines
Message-Id: <35BF66F1.51278300@acm.org>
>From one newbie to another:
would this work?
chomp($String);
or
$VariableName = chomp("$String");
Melinda Quinn melinda@acm.org
Terrence E. S. Thompson wrote:
> >
Hi, I've got a problem that is just driving me crazy. I've looked
> in the manual and the faq, but I'm just not getting it. How exactly
> do I remove a newline from the end of a string?
>
> I tried this:
>
> $string =~ s/(.+)\n$/$1/;
>
> but it doesn't seem to work.
>
> Sorry if this a dumb question, but I'm really stuck.
> Thanks for any help!
------------------------------
Date: Wed, 29 Jul 1998 18:09:09 GMT
From: fhurtubi@videotron.net (Fred Hurtubise)
Subject: Re: Code for deciding week number?
Message-Id: <35bf64be.17679091@news.videotron.net>
On Sun, 26 Jul 1998 16:14:09 +0200, Thomas Jespersen
<thomas@daimi.aau.dk> wrote:
>Thomas Albech wrote:
>>
>> Hi everyone,
>>
>> How do you mathematically decide, which week number we are currently in?
>> Is there any expression for it
>> in combination with the Time module?
>>
>> Thanks,
>> Thomas
>
>perldoc perlfaq4
>
>Look for:
>
>How do I find the week-of-the-year/day-of-the-year?
Or use Date::Manip
------------------------------
Date: 29 Jul 1998 14:04:42 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Dereferencing Hashes and Arrays
Message-Id: <6pno7q$h0a$1@monet.op.net>
In article <35BF5439.647F1207@mail.arc.nasa.gov>,
Roger Smith <rogersmith@mail.arc.nasa.gov> wrote:
>This is a multi-part message in MIME format.
> $givenname = @$entry{'givenname'}; # first name
$givenname = $entry->{'givenname'}[0]
or
@given_names = @{$entry->{'givenname'}}
or
($givenname) = @{$entry->{'givenname'}}
You seem to be confused abut basic syntax. You might want to take a
look at my article `Understand References Today'. It is at
<URL:http://www.plover.com/~mjd/FAQs/>
------------------------------
Date: Wed, 29 Jul 1998 13:26:34 -0500
From: christopher michael mabee <mabee@students.uiuc.edu>
Subject: Finding online users
Message-Id: <Pine.SOL.3.96.980729132221.17190A-100000@ux7.cso.uiuc.edu>
Hello. I am trying to write a script to find out when certain users
come on line. So when say "bob" logs on I get a message saying "bob is
logged on" or something like that. I'm fairly new to the language and any
help is appreciated. Thanks.
Chris
------------------------------
Date: Wed, 29 Jul 1998 18:35:23 GMT
From: dan@NOSTINKINSPAM.nwsl.west.ga.net. (Daniel)
Subject: Re: Glob problem
Message-Id: <LXJv1.861$U_4.1526332@news1.atl.bellsouth.net>
LAst time <Pine.GSO.4.02.9807290932490.19378-100000@user2.teleport.com>, Tom Phoenix <rootbeer@teleport.com> said whatever is quoted below
>On Wed, 29 Jul 1998, Daniel wrote:
>
>> open(MYNEWFIL,"/dbase.txt");
>
>Even when your script is "just an example" (and perhaps especially in that
>case!) you should _always_ check the return value after opening a file.
I usually use a die here. I cut out some stuff to keep it to the basic
problem.
>
>> local (*GLOB) = $name;
>> $GLOB = $value;
>
>You probably want to use a hash instead of this.
Great, I've gotta learn hashes now <g>.. Thanks for the help.
Dan
Mic 6:8 He hath shewed thee, O man, what is good; and what doth
the LORD require of thee, but to do justly, and to love mercy,
and to walk humbly with thy God?
------------------------------
Date: 29 Jul 1998 19:17:16 GMT
From: "Lance Hollman" <lance@nospam.net-school.com>
Subject: Re: hiding user input
Message-Id: <01bdbb25$1d5f2280$24f186cd@myname>
Scott Stark <sstark@informix.com> wrote in article
<6pnm5m$3gh1@webint.na.informix.com>...
> Is there any way to make user input in a perl script invisible, or
showing a
> series of **** characters instead of what's typed? My script prompts the
user
> for a password and currently anyone watching can see the input.
>
Check out the Term::ReadKey module on CPAN.
Lance
------------------------------
Date: Wed, 29 Jul 1998 19:36:42 GMT
From: fhurtubi@videotron.net (Fred Hurtubise)
Subject: Re: hiding user input
Message-Id: <35bf78fc.22861389@news.videotron.net>
On 29 Jul 1998 17:29:26 GMT, sstark@informix.com (Scott Stark) wrote:
>Is there any way to make user input in a perl script invisible, or showing a
>series of **** characters instead of what's typed? My script prompts the user
>for a password and currently anyone watching can see the input.
>
>thanks
>Scott Stark
>sstark@informix.com
If you mean in an HTML page, go get a HTML book and check
the attributes you can give to the input tag...specially the
password one...
If you meant on the command line...i have no clue
------------------------------
Date: 29 Jul 1998 19:40:29 GMT
From: william@host.ott.igs.net (William Wueppelmann)
Subject: Re: I want to separate my Perl from my HTML
Message-Id: <6pntrd$l46$3@news.igs.net>
pjgeer@my-dejanews.com wrote:
: I write CGIs that output HTML. I want to separate the HTML from the Perl so I
: can edit (or have someone else edit) just the HTML by itself, without worrying
: about busting the script. I had been using here docs to handle blocks of HTML
: but I get mad about things like the code below. How can I separate the HTML
: from the Perl?:
: print <<"EOF";
: ...
: <SELECT Name="languages">
: EOF
: foreach $record ( @records ) {
: print "<OPTION Value=\"$record.txt\">$record</OPTION>\n";
: }
: print <<"EOF";
: </SELECT>
: EOF
You can put your HTML code in a separate .html file and include a code in
the HTML document that indicates where you want to insert your generated
data e.g.:
doc.html
<HTML>
<BODY>
<<insert>>
</BODY>
</HTML>
makedoc.pl
open(FH, "doc.html") or die($!);
$doc = join("", <FH>);
close FH;
foreach $record (@records) {
$insert .= "<OPTION value=\"$record.txt\">$record</OPTION>\n";
}
$doc =~ s/<<insert>>/$insert/e;
$doc = "content-type: text/html\n\n" . $doc;
print $doc;
William
------------------------------
Date: Wed, 29 Jul 1998 19:35:43 +0100
From: "P. Hegarty" <shadolin@cableinet.co.uk>
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <35BF6B7E.13FA224D@cableinet.co.uk>
This is a multi-part message in MIME format.
--------------D053FFD5CD761107260EB58A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I though the course I was on encourage us to use the internet to its full
capacity, meaning using it to find solutions to problems.
Anyway I think it was the correct course, so if you think it is you can ignore
this message and send me some help.
I.J. Garlick wrote:
DON'T give him the answer this is homework.
> Nice try Parrick. Now work it out for yourself, afterall you told me
> yesterday it was a 'piece of cake'.
>
> What is even more staggering is that you could imagine we don't read this
> news group!!!
>
> --
> Ian J. Garlick
> ijg@csc.liv.ac.uk
>
> Who watches the Watchmen.
--
Have Fun!!!
Shadolin
******************************************************************************
Patrick Hegarty shadolin@cableinet.co.uk
102 Jubilee Drive sm8plh@csc.liv.ac.uk
Liverpool http://wkweb4.cableinet.co.uk/shadolin/
L7 8SM http://www.csc.liv.ac.uk/~sm8plh/
0151 281 4510 Fax 0151 281 7123
*****************************************************************************
--------------D053FFD5CD761107260EB58A
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Patrick Hegarty
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Patrick Hegarty
n: Hegarty;Patrick
org: WITS
adr: 84 Claremont Road;;Wavertree;Liverpool;Merseyside;L15 3HL;U.K.
email;internet: shadolin@cableinet.co.uk
tel;fax: 0151 281 7123
tel;home: 0151 281 4510
note: sm8plh@csc.liv.ac.uk During working Hours
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
version: 2.1
end: vcard
--------------D053FFD5CD761107260EB58A--
------------------------------
Date: Wed, 29 Jul 1998 19:38:21 +0100
From: "P. Hegarty" <shadolin@cableinet.co.uk>
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <35BF6C1D.CF1930A4@cableinet.co.uk>
This is a multi-part message in MIME format.
--------------4EFB16778858FCE51CD94432
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Simon Fairey wrote:
> I'm curious are we talking a script to emulate 'cat' or 'type' or are we
> talking about a script which does nothing but print itself, without I assume
> using open() or the obvious system() call?
>
A script that does nothing but print out exact what is in the script without
reading anything into the script or using a any system calls.
--
Have Fun!!!
Shadolin
******************************************************************************
Patrick Hegarty shadolin@cableinet.co.uk
102 Jubilee Drive sm8plh@csc.liv.ac.uk
Liverpool http://wkweb4.cableinet.co.uk/shadolin/
L7 8SM http://www.csc.liv.ac.uk/~sm8plh/
0151 281 4510 Fax 0151 281 7123
*****************************************************************************
--------------4EFB16778858FCE51CD94432
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Patrick Hegarty
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Patrick Hegarty
n: Hegarty;Patrick
org: WITS
adr: 84 Claremont Road;;Wavertree;Liverpool;Merseyside;L15 3HL;U.K.
email;internet: shadolin@cableinet.co.uk
tel;fax: 0151 281 7123
tel;home: 0151 281 4510
note: sm8plh@csc.liv.ac.uk During working Hours
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
version: 2.1
end: vcard
--------------4EFB16778858FCE51CD94432--
------------------------------
Date: Wed, 29 Jul 1998 19:41:46 +0100
From: "P. Hegarty" <shadolin@cableinet.co.uk>
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <35BF6CE9.DB87FB24@cableinet.co.uk>
This is a multi-part message in MIME format.
--------------E02E8E0F5D8D24AB2A69E3E0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Thomas Jespersen wrote:
> P.L. Hegarty wrote:
> >
> > Firstly I will apologise if this question is answered anywhere else, but I'm in
> > a bit of a rush and
> > have not been able to get the FAQ for this group yet.
>
> But you have been able to get Perl?
>
> Strange!
Not really since I am on a university unix system and therefore did not install
Perl.What I meant was that I have not been reading this group for very long and have
not seen a post of the FAQs or had time to go and find out where someone might have
store it. I have a FAQ from CPAN but this question wasn't answered in it.
--
Have Fun!!!
Shadolin
******************************************************************************
Patrick Hegarty shadolin@cableinet.co.uk
102 Jubilee Drive sm8plh@csc.liv.ac.uk
Liverpool http://wkweb4.cableinet.co.uk/shadolin/
L7 8SM http://www.csc.liv.ac.uk/~sm8plh/
0151 281 4510 Fax 0151 281 7123
*****************************************************************************
--------------E02E8E0F5D8D24AB2A69E3E0
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Patrick Hegarty
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Patrick Hegarty
n: Hegarty;Patrick
org: WITS
adr: 84 Claremont Road;;Wavertree;Liverpool;Merseyside;L15 3HL;U.K.
email;internet: shadolin@cableinet.co.uk
tel;fax: 0151 281 7123
tel;home: 0151 281 4510
note: sm8plh@csc.liv.ac.uk During working Hours
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
version: 2.1
end: vcard
--------------E02E8E0F5D8D24AB2A69E3E0--
------------------------------
Date: Wed, 29 Jul 1998 19:17:01 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Is it possible
Message-Id: <EwvEwD.1D0@world.std.com>
"Patrick L. McGillan" <mcgillanp@mndulu.ang.af.mil> writes:
>I can't seem to figure out how to control a serial port. Is it possible with
>perl? I would like to do some low level i/o to a serial port.
If the OS you are using is Unix, and if the "low level I/O" you want
to do is supported by the terminal drivers, then you might want to use
the POSIX::Termios functions found in the POSIX module.
If you are using Unix and the "low level I/O" you want to do is too
low level for the terminal driver provides (For example, the terminal
driver has certain meanings assigned to the DTR,CD, signals), you'll
probably have to write your own driver, and that won't be possible in
perl.
If the OS you are using is not Unix, then POSIX::Termios won't work,
but there might be some other options (The Mac OS's Communications
Toolbox can be called from MacPerl through GUSI. For Windows, someone
is working on a Win32::SerialPort module info is available at
<URL:http://members.aol.com/Bbirthisel>)
--
Andrew Langmead
------------------------------
Date: 29 Jul 1998 18:04:30 GMT
From: huliang@almaden.ibm.com (Hu Liang)
Subject: loggin out of CGI authenticated state
Message-Id: <6pno7e$fhm@fox.almaden.ibm.com>
My server currently authenticates a person through DCE before allowing them to
run any protected CGI scripts. However, this user/password pair resides in
Netscape as long as one copy of it is open. So for a new user to login, all
netscape sessions has to be shutoff...a real pain. I've seen a few pages
having a "logout" feature that erases this state information... how it that
accomplished and can it be done with perl?
Thanks in advance.
Hu
Please email huliang@almaden.ibm.com is possible.
------------------------------
Date: Wed, 29 Jul 1998 13:58:44 -0400
From: joe.mcmahon@gsfc.nasa.gov (Joe McMahon)
Subject: Re: Misleading documentation
Message-Id: <joe.mcmahon-2907981358440001@prtims.stx.com>
In article <6plv4m$caq$1@monet.op.net>, mjd@op.net (Mark-Jason Dominus) wrote:
>In article <joe.mcmahon-2807981338590001@prtims.stx.com>,
>Joe McMahon <joe.mcmahon@gsfc.nasa.gov> wrote:
>>Note: I am NOT asking a question, but pointing out what I feel is an
>>ambiguous meaning, or perhaps an oversight, in a Perl error message.
>
>I wish you'd post a small example that demonstrates your problem,
>because I read it twice and didn't understand it, and when I read it a
>third time I thought I understood it but the thing it seemed to
>describe was impossible.
>
I'll break it again and then try to create a trivial example that
demonstrates it. The weird way that the class method call worked and the
instance method one didn't was what had me confused as well.
--- Joe M.
------------------------------
Date: Wed, 29 Jul 1998 17:53:35 GMT
From: mickghazey@my-dejanews.com
Subject: open IN, "file " or die <= it dies!
Message-Id: <6pnniv$550$1@nnrp1.dejanews.com>
I'm unable to open a file name that has a trailing space.
open IN, "file " or die; <= this dies!
open In, quotemeta "file " or die; <= this dies too
rename "file ", "file" or die; <= this works!
I've verified this on Solaris using perl 5.003 and on Linux using perl 5.004.
Help!
Thanks
Mick
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 29 Jul 98 19:53:21 +0000
From: "Adam Atkinson" <ghira@mistral.co.uk>
Subject: Re: perl as pseudocode
Message-Id: <4689.514T1072T11933429@mistral.co.uk>
On 27-Jul-98 15:43:25, Lavoie Philippe said:
>To answer your question, since I'm new to perl too and don't really
>care about $j != undef.
Well, it's not that I don't care about it... I've kicked myself
and have attempted to make a mental note not to do it again.
(One problem is that I'm in serious danger of trying to run before
I can walk - I half-remember too many things. Currently references
have me stopped dead. I appear to be implicitly using them when
I use multi-dimensional arrays or hashes)
>I'd do the following,
>create a pseudo->real perl script (and perl->pseudo script to).
>That script will convert some of your pseudo construct to normal perl
>constructs. Of course don't show that script to others because they'll
>be completely bewildered by what's going on.
Ewwww.... that sounds like far more work than writing non-idiomatic
but working scripts in the first place. :-)
The context is that I'll have explained hand-wavingly how something
is done, and perhaps done a small case on a blackboard (or, in the
Huffman code case, by moving 3x5 inch cards about and building a tree
out of them on the table).
The perl script was there so I could do it with more realistically
sized examples, and demonstrate what increasing block sizes did.
>The perl->pseudo script will create a database of the symbols you are
>using and will change all references to $var to var. I find it's more
>readable for neophyte without the $.
Ah.. hmm.. I see where you're coming from now. Clearly this is
one of the reasons my question was mostly futile... who is the
audience? I was thinking that telling them not to worry about
$ was ok. Indeed, I thought that hashes and arrays would both
be fine since I wouldn't mention the difference.
I was thinking more about things like "Does heavy use of default
arguments make perl more or less useful as pseudocode?". and
things like "hard" regular expressions, map, tr, and so on.
I _suspect_ that a foreach (1..n) style loop is more acceptable
as fake pseudocode than the imitation-C style "for (i=1;i<=n;i++)"
(though I should admit my huffman program was originally written
with c-style loops since at the time I wrote it they were the only
kind I knew about)
>So the followiong code would become
>Now from the above some things are still perl-specific. the use of
><SYMBOLS>, the use of $_, the use of (var,var) = (...) and finally
>chomp.
well, I'm willing to live with a certain amount of that kind of thing.
"(var, var) =" can probably go, though
>So, have the perl->pseudo expand these to something more legible.
>Also, you don't need the ; in pseudo-code.
the idea was to show the program on the screen in a text editor
(we have one of those computer-driven projector things, you see),
show some example data files in the text editor, and then
feed them to the program to show what happens
>The line inside the while loop is still a bit unreadable to non-perl
>programmers. You can probably change it from
> (symbol[i] , prob[i]) = seperate the current line at ' '
>to
> seperate the current line at ' ' then put the result in symbol[i] and
> prob[i]
yep, I'd agree with that
>The pseudo->perl script could convert back that line with something like
>So the final version is
> die "Can't find symbol table" unless open(SYMBOLS,ARGV[0])
> i = 0
> entropy = 0
> while(a line in SYMBOLS>) {
> seperate the current line at ' ' then put the result in symbol[i] and
> prob[i]
> }
> remove the trailing new lines characters from prob[i]
>I hope this is what you were looking for. Have fun with the converting
>script and put in on CPAN when it's done ;)
Hmm. I have to admit this isn't what I was originally thinking about,
but the idea is intriguing (um. sp?)... a perl "pseudocodifier"...
another relatedish context is recreational maths newsgroup-like
things where I sometimes have to say very precisely how I do something.
pseudocode or an actual program is useful in such cases too. up until
a few years ago I used to use something that was, or very nearly was,
a program in BASIC. I suppose that's not very "credible" these days...
and I'm sure a suitably written perl program could be made to look
nicer than C could. if it actually works in some environment, that's
a sort of plus. even if perl is far too slow for the thing to work
sensibly. a good example here would be discussion of a problem about
"optimising the denominations of stamps to issue subject to certain
criteria" a few months ago where "explaining" the approaches in words
became totally unviable very quickly.
--
Adam Atkinson (ghira@mistral.co.uk)
#include <disclaimer.h>
------------------------------
Date: 29 Jul 1998 19:45:40 GMT
From: Thomas van Gulick <melkor@valimar.middle.earth>
Subject: Perl variable types problems
Message-Id: <6pnu54$anj$1@dinkel.civ.utwente.nl>
Why does perl sometimes generate wrong results when using the AND operator.
An example:
${$clan_one}{GAMETYPES} = 31;
${$form}{GAMETYPE} = 4;
then ${$clan_one}{GAMETYPES} & ${$form}{GAMETYPE} results in 0 instead of
the expected 4. This happens in my source code and is probably not easily
reproduced in other sources. When I simply print 31&4 it does result in the
correct answer.
If you're interested, the complete sourcecode can be found at:
http://utumno.student.utwente.nl/~quake/sources/scripts/wars/include.pm
http://utumno.student.utwente.nl/~quake/sources/scripts/wars/new
Thomas
--
http://utumno.student.utwente.nl/
melkor@utumno.student.utwente.nl
------------------------------
Date: 29 Jul 1998 14:36:54 -0500
From: nem@abattoir.cc.ndsu.nodak.edu (Nem W Schlecht)
Subject: Re: Perl5.005: any good Thread::kill workaround ideas?
Message-Id: <6pntkm$nk4@abattoir.cc.ndsu.nodak.edu>
In comp.lang.perl.misc, Andreas Greulich <andreas.greulich@mbox.bfi.admin.ch> wrote:
>be cancellable. This might be the reason no such call was implemented
>in Perl? Anyway, it might still be possible to call pthread_cancel directly
>as a system call using the Thread-ID. See the pthread_cancel manpage.
I would be very weary of trying to do this myself in a perl script!
>>It would be nice to have something like Thread:kill, but there is none.
I, too, am looking for a way to do this, but also realize that thread
support in perl is still considered to be in the development stage.
Hopefully, the developers will come up with something like the following in
the near future. (There's most likely a much better way of doing this than
what I'm suggesting!)
#!/local/bin/perl
# WARNING - This code does not work.
use Thread;
sub do_wait { sleep(3); print "Hello!\n"; }
my($t) = new Thread &do_wait;
$t->cancelstate($Thread::CANCEL_ENABLE);
$t->canceltype($Thread::CANCEL_DEFERRED);
sleep(1);
$t->cancel(); # ask for thread cancelation
my($ret) = $t->join(); # get return code from pthread_exit
This should take ~1 second to run, and should *not* print 'Hello!'.
--
Nem W Schlecht nem@plains.nodak.edu
NDUS UNIX SysAdmin http://www.nodak.edu/~nem/
"Perl did the magic. I just waved the wand."
------------------------------
Date: Wed, 29 Jul 1998 19:18:57 GMT
From: ultrasparc@my-dejanews.com
Subject: removing accented characters from a string
Message-Id: <6pnsj1$c6r$1@nnrp1.dejanews.com>
Hello all,
How could I have the "tr" expression replace any accented letter with an
English letter?
My perl script needs to read in a name and screen it for any of these
characters because it creates file directories on disk based on that name.
It needs to retain all of the standard alphanumeric characters (letters,
numbers, underscore, etc) but must change the accented characters (and any of
the other special characters, for that matter).
Example: Muqoz must be converted to Munoz.
If translation isn't possible, is there a regular expression that searches for
these accented characters?
Any help would be greatly appreciated, thanks.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 29 Jul 1998 19:43:11 GMT
From: c20xe@my-dejanews.com
Subject: Sending out eMails in predefined intervals ?
Message-Id: <6pnu0f$dts$1@nnrp1.dejanews.com>
Hello,
I'm searching the net for month now, but don't
find a script, I need to manage some outgoing
eMails.
On my website I have a section of about 20
articles and now I want to offer the vistors
to receive this articles by eMail.
They should choose the intervals of receiving
the eMails. This should be realized with a
HTML-Form drop-down-menue, content of the
form field would be, for example, "want to
receive one mail *daily*", "want to receive
one mail per *week*", ... and so on ...
Can anybody help ?
Are there any scripts available doing just
that (sending out eMails in predefined
intervals) ?
You can write to NG or private:
<mailto:andreas.frenko@gmx.de>
Sincerely,
Andreas Frenko
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 29 Jul 1998 19:14:52 GMT
From: william@host.ott.igs.net (William Wueppelmann)
Subject: Re: Submit only Once
Message-Id: <6pnsbc$l46$1@news.igs.net>
Sam Irion (persoft@concentric.net) wrote:
: Can anyone give me any advice or direction on how to prevent the user from
: using the browser's back button to go back to a form and repost it?
: I have a perl script that send out a couple of emails after a large form is
: posted. The form has a lot of required fields. My thoughts are that if I
: can prevent the user from backing up and posting the same data again (by
: offering a new reset form), those that are inclined to back up and submit
: dozens of times won't feel like it is worth the effort.
: Any advice will be appreciated!
have the form generated via a CGI script, which will embed in the form an
acession number as a hidden field e.g.:
<input type="hidden" name="uid" value="123">
When the script is processed, do the following:
1. check a data file that contains a list of all submitted acession
numbers. If the "uid" field matches any of those fields, do not process
the rest of the data, and instead return a blank form (with a new
accession number) and possibly an explanitory message.
2. if the accession number isn't in the data file, add it. Then increment
it and write the incremented accession number to a file which will be read
by the CGi script that generates the form to determine the accession
number.
3. Process the form as usual.
There are ways around this (the user could just enter the query string by
hand and change the acession number each time, I suppose), but I'm
assuming that few people if any are really going to try that hard to CGI
spam you, in which case it should offer enough protection.
William
------------------------------
Date: 29 Jul 1998 19:21:05 GMT
From: william@host.ott.igs.net (William Wueppelmann)
Subject: Re: Submit only Once
Message-Id: <6pnsn1$l46$2@news.igs.net>
- (root.noharvest.\@not_even\here.com) wrote:
: Or perhaps.... have the form created by another script that generates
: a unique ID, and then in the recieving script, if you encounter a
: "used" ID, don't allow the process to continue. If the ID has not
: been seen before, good - send the message.
: This would require keeping a small file, probably just the unique ID,
: or an incremented number, and then reading it as the first step in
: determining what to do.
I think you'd actually have to keep a file of all used UID numbers. If
you only keep track of the last issued or last submitted UID something
like this could happen:
- UID = 0
- person A requests the form, the form is given UID 1
- UID = 1
- person B requests the form, the form is given UID 2
- UID = 2
- person A submits the form. UID 1 is less than the current UID, so the
form is rejected. Given the number of fields that have to be filled in,
person A is understandably unhappy with the prospect of having to grab
a brand new form.
You could periodically reset the list of used numbers so it doesn't take
very long to re-read through them. Say every time you reach 2000 used
numbers, remove the oldest 1000 from the list.
William
------------------------------
Date: 29 Jul 1998 18:41:28 GMT
From: bday@cbr.eng.sun.com (Brian Day)
Subject: sytem( ) calls in CGI scripts
Message-Id: <6pnqco$frq$2@engnews2.Eng.Sun.COM>
Keywords: CGI system
I was wondering if anybody could explain why system() calls are not working
in my CGI scripts. Everything else works fine, but when I try to use:
system("cd /home/brandond/expl_db");
system("ls -1 explorer* > temp");
and then try to print out the listing of temp in an html document, nothing
happens. If I create the file temp with the listing manually, the rest of
the CGI script opens it and prints it out fine, so I know the problem lies
with the system() calls. Nowhere in my CGI w/Perl books does it explain
process management. Is this not possible.
Any help would be greatly appreciated.
Thank You,
Brian
---
Brian T. Day
email: bday@Eng.sun.COM
voice: (650) 336-1331
Sun Microsystems, Inc.
mailstop: UMTV03-02
901 San Antonio Rd
Palo Alto, CA 94303-4900
------------------------------
Date: 29 Jul 1998 15:56:20 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: sytem( ) calls in CGI scripts
Message-Id: <6pnup4$i46$1@monet.op.net>
Keywords: CGI system
In article <6pnqco$frq$2@engnews2.Eng.Sun.COM>,
Brian Day <bday@cbr.eng.sun.com> wrote:
>system("cd /home/brandond/expl_db");
>system("ls -1 explorer* > temp");
`system' creates a subprocess in which to execute the command. When
you do system('cd ...'), the subprocess executes the cd command, which
changes its working directory, and then the subprocess exits. The
current directory of the parent process, in which your script is
running, is unaffected.
Then the second `system' inherits the current directory from your
script, which and this directory has not changed.
To change directory, use
chdir "/home/brandond/expl_db"
or die "Couldn't chdir to /home/brandond/expl_db: $!; aborting";
That "ls -1" thing is really suspect. At the very least, you probably
want:
open (LS, "ls -1 explorer |")
or die "Couldn't run ls: $!; aborting";
# Read LS just as if it were the temporary file
This avoids the temporary file. If two people hit your program at the
same time, one of them might ruin the other one's temporary file while
it was being read; the pipe version I showed avoids that.
Even simpler version:
chomp(my @files = qx{ls -1 explorer*});
# Now the list of files is in @files.
------------------------------
Date: 29 Jul 98 18:57:42 GMT
From: rpete@ascda3.harvard.edu (Pete Ratzlaff)
Subject: Re: This is an easy question!
Message-Id: <35bf70a6.0@cfanews.harvard.edu>
Patrick Boswell (patb@ufl.edu) wrote:
> I am working with CGI and perl, and I am currently trying to hack up some
of Selena Sol's code. I'm trying to split
> this Shopping Cart as listed below on the | symbol, where upon each field
I will perform some calculations. However,
> when I try to split this file, I am able to do this, but it only splits up
until the first line. It's like after it's
> done splitting or finds the first reference, it stops. Any help?
Please get a newsreader that knows how to split lines :)
>
>
> #! /usr/bin/perl
> open(CART,"/home/p/patrickb/pattest.com_html/User_carts/4966912.8222.cart");
> while (<CART>) {
> @cart_lines = split (/\d\d\r\d\d/);
> close(CART);
> #@cart_fields = split (/\|/, @cart_lines);
> #notice how the above will not work because at the end of the lines there is no |
> while ($i <= 20) {
> #$toreturn = $cart_fields[$i];
> $toreturn = $cart_lines[$i];
> print " $toreturn \n";
> $i++;
> }
> }
>
First, the close(CART) statement will stop the file reads after the
first line.
Also, split(/\|/, @cart_lines) is almost certainly not doing what you
seem to think it should. You probably want a scalar in place of @cart_lines.
Do 'perldoc -f split' for more info.
Finally, you don't reinitialize $i after going through your while($i <= 20)
block. This means the block will not be executed after the first line was
read from your file.
Perhaps you should read up a little more on the language. Try "Learning Perl"
by Schwartz and Christiansen for starters.
-------------
Peter Ratzlaff Harvard-Smithsonian Center for Astrophysics
Office B102 60 Garden St, MS 21, Cambridge MA 02138 USA
<pratzlaff@cfa.harvard.edu> phone: 617 496 7714
------------------------------
Date: 29 Jul 1998 18:00:06 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6pnnv6$p78$1@news.NERO.NET>
In article <6plpno$kne$1@marina.cinenet.net>,
Craig Berry <cberry@cinenet.net> wrote:
>John Stanley (stanley@skyking.OCE.ORST.EDU) wrote:
>: >+ Are you sure it's not the year 100? Are you also sure that "1900" is not
>: >+ the year 3800?
>:
>: >Yes. By *definition*. As per 'perldoc -f localtime':
>:
>: I see nothing related to perl in the string 02-29-100.
>
>Your whole argument rests on an (intentional?) confusion between the data
>and the presentation of that data, or the 'model' and the 'view' to steal
>terms from one of my favorite design philosophies.
No, my "whole argument" rests on the fact that 02-29-100 is the
presentation of the data, and as such, it is not as unambiguous at it
is claimed to be.
>: If I am your pointy haired boss and you hand me a report with that date
>: in it, I have no way of knowing that you programmed in perl.
>
>Nobody is proposing that you use the raw localtime year value in
>human-viewable output; the fact that some misguided people did so is one
>of the core causes of the whole y2k problem.
That's right. And what I was replying to was the comment that 02-29-100
is not ambiguous. I don't intend on using raw localtime output, nor have
I ever said that it was the right thing to do.
>: For every two digit year printed on any sheet of paper,
>: or contained in any database, there is someone who has private knowledge
>: as to how that number was produced. There can be no ambiguity.
>
>Yes there can, if others use that database/paper without the same
>knowledge.
That is my point. The argument is called 'reductio ad absurdum'. The
assumption that one person knows the format so there is no ambiguity
leads to a ridiculous conclusion, thus the assumption is questionable.
You can usually detect such arguments because they start, as mine did,
with a statement similar to "if we assume your statement is correct..."
------------------------------
Date: 29 Jul 1998 18:03:09 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6pno4t$p8b$1@news.NERO.NET>
In article <1dcwkn3.14voao11uuryvbN@bay1-205.quincy.ziplink.net>,
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
>John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>
>> I see nothing related to perl in the string 02-29-100. If I am your
>> pointy haired boss and you hand me a report with that date in it, I
>> have no way of knowing that you programmed in perl. "Dates will be the
>> output of the 'localtime' perl funtion" is not how any company I know
>> of standardizes its dates. "Dates will be expressed as the last two
>> digits of the year" is.
>
>Then add 1900 to the year when you print the report. Duh. It's not
>Perl's fault if you don't know how to program.
I'm sorry you didn't follow the context of the discussion. I am not
printing the report. I am not the one programming this example. I am
pointing out that 02-29-100 is not an unambiguous way of representing
the date. Period.
>You really do argue about the stupidest things.
Then you see some perl-related content in the string 02-29-100, and you
can tell just by looking at it that it is the output of 'localtime'? Or
you just didn't bother reading what you replied to?
------------------------------
Date: 29 Jul 1998 18:12:10 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6pnolq$pau$1@news.NERO.NET>
In article <6pnhr5$hdg@mozo.cc.purdue.edu>,
Michael J Gebis <gebis@albrecht.ecn.purdue.edu> wrote:
>stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
>
>}I see nothing related to perl in the string 02-29-100. If I am your
>}pointy haired boss and you hand me a report with that date in it, I
>}have no way of knowing that you programmed in perl. "Dates will be the
>}output of the 'localtime' perl funtion" is not how any company I know
>}of standardizes its dates. "Dates will be expressed as the last two
>}digits of the year" is.
>
>Does the following program have a bug?
I don't know. I also don't know how it relates to the paragraph of mine
you quoted.
>#!/usr/bin/perl -w
>use strict;
>print "Today's date is ",localtime;
>
>If yes: Is it a bug in perl, or a bug in how I'm using localtime?
Let's see.
onyx 104: ./nn
"use" may clash with future reserved word at ./nn line 2.
Syntax error in file ./nn at line 2, next 2 tokens "use strict"
Execution of ./nn aborted due to compilation errors.
Yep, it has a bug. At least, not running at all would be considered to
be a bug by most people. Now let's try it under perl 5.
#!/usr/local/bin/perl5 -w
use strict;
print "Today's date is ",localtime;
onyx 106: ./nn
Today's date is 246112969832091onyx 107:
At this point, nobody knows but you, since you did not bother to include
a single comment as to the desired funtion of your program. If you need
no newline at the end, and you want the string as it was returned, then
there appears to be no bug.
------------------------------
Date: Wed, 29 Jul 1998 18:32:29 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <1VJv1.127$9t2.1498175@news3.voicenet.com>
John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>I am
>pointing out that 02-29-100 is not an unambiguous way of representing
>the date. Period.
Why is it so hard to follow the documentation? An end user should
_never_ see the date "02-29-100". If they did, then the programmer
introduced his own date bug.
If this is not the case, then no programs have bugs. Is it a bug to
dump a binary image to STDOUT instead of eval()ing it, or exec()ing it?
Shoudln't just opening it to STDOUT work?
Of course not. The language works in specific ways. You have to follow
the rules, or it won't work.
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: 29 Jul 1998 19:24:09 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6pnssp$l7i@mozo.cc.purdue.edu>
stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
}>#!/usr/bin/perl -w
}>use strict;
}>print "Today's date is ",localtime;
}>If yes: Is it a bug in perl, or a bug in how I'm using localtime?
}#!/usr/local/bin/perl5 -w
}use strict;
}print "Today's date is ",localtime;
}onyx 106: ./nn
}Today's date is 246112969832091onyx 107:
}At this point, nobody knows but you, since you did not bother to include
}a single comment as to the desired funtion of your program. If you need
}no newline at the end, and you want the string as it was returned, then
}there appears to be no bug.
Nope. I wanted to see "7/29/98".
Why didn't I?
I suspect it's because I didn't process the output of locatime
correctly. By some strange coincidence, this might have some sort of
relevance to the original post.
I do agree with the fact that 7/29/100 is a bad way of representing
the date two years from now. Maybe that's your whole point. My point
is that it's not perl's fault that people can misuse localtime and get
things like 7/29/100.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 29 Jul 1998 19:01:42 GMT
From: "joe" <jsteorts@csc.com>
Subject: Year 2000
Message-Id: <01bdbb23$e65324e0$d445e1c0@C-105813.gsfc.nasa.gov>
I was wondering about Perl and the Year 2000.
Is Perl Version 5.004 year 2000 compliant?
If not, are there plans for a Year 2000 compliant release?
Are the LWP packages (HTML Parser, libnet, data dumper, MIME, MD5, and
libwww) year 2000 compliant?
Thank You
------------------------------
Date: 29 Jul 1998 15:43:04 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Year 2000
Message-Id: <6pnu08$hvj$1@monet.op.net>
In article <01bdbb23$e65324e0$d445e1c0@C-105813.gsfc.nasa.gov>,
joe <jsteorts@csc.com> wrote:
>Is Perl Version 5.004 year 2000 compliant?
Only in the same sense that a pencil is.
>Are the LWP packages (HTML Parser, libnet, data dumper, MIME, MD5, and
>libwww) year 2000 compliant?
What exactly are you asking here?
What do you think `year 2000 compliance' is?
------------------------------
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 3288
**************************************