[23084] in Perl-Users-Digest
Perl-Users Digest, Issue: 5305 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 1 11:10:34 2003
Date: Fri, 1 Aug 2003 08:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 1 Aug 2003 Volume: 10 Number: 5305
Today's topics:
Re: question from perl noob <no_thanks@bms.umist.ac.uk>
Re: question from perl noob <no_thanks@bms.umist.ac.uk>
Re: question from perl noob <no_thanks@bms.umist.ac.uk>
Re: question from perl noob <me@privacy.net>
Re: Substitution Question <no_thanks@bms.umist.ac.uk>
Re: Substitution Question <mikeflan@earthlink.net>
Re: using post method (Tad McClellan)
Wait for directory changes in Windows XP? <usenet_removebeforesending_@fatkoala.co.uk>
Re: Wait for directory changes in Windows XP? <jimbo@soundmiges.co.uk>
Re: Web development and Perl 6 <none@none.com>
Re: Web development and Perl 6 <wsegrave@mindspring.com>
Re: Web development and Perl 6 <cwilbur@mithril.chromatico.net>
Re: Web development and Perl 6 <cwilbur@mithril.chromatico.net>
Re: Web development and Perl 6 <none@none.com>
Re: Web page with frames... <me@privacy.net>
Re: win32 - kill 0 and handle leaks. <hyagillot@tesco.net>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 01 Aug 2003 10:10:20 +0100
From: Chris <no_thanks@bms.umist.ac.uk>
Subject: Re: question from perl noob
Message-Id: <3f2a38ba$1@news.umist.ac.uk>
boblehue wrote:
> Hi
>
> I'm tryng to learn a little perl and have a problems with decimal's.
>
> This asignment is to rewrite this code to not print more the two decimals
> with the use of INT operator, multiplication, and division.
>
<snip>
The trick is to multiply everything up by 100 so that you're working in
pence, cents, or whatever currency you're dealing with. Then do your
monthly interest multiplication forced to INT and then divide you're
final answer by 100 to get back you're 2 dec. points.
Chris.
------------------------------
Date: Fri, 01 Aug 2003 10:14:29 +0100
From: Chris <no_thanks@bms.umist.ac.uk>
Subject: Re: question from perl noob
Message-Id: <3f2a39b3$1@news.umist.ac.uk>
Garry Short wrote:
<snip>
> $total= sprintf "%2f", ($pmt * ( ( (1 + $interest) ** $mons ) -1 )/
> $interest);
<snip>
That should be:
$total= sprintf "%.2f", ($pmt * ( ( (1 + $interest) ** $mons ) -1
)/$interest); ^
Your code tries to round the float to two sig. figs not two dec. places.
The dot will remedy that.
------------------------------
Date: Fri, 01 Aug 2003 11:34:30 +0100
From: Chris <no_thanks@bms.umist.ac.uk>
Subject: Re: question from perl noob
Message-Id: <3f2a4c74$1@news.umist.ac.uk>
Chris wrote:
> boblehue wrote:
>
>> Hi
>>
>> I'm tryng to learn a little perl and have a problems with decimal's.
>>
>> This asignment is to rewrite this code to not print more the two decimals
>> with the use of INT operator, multiplication, and division.
>>
> <snip>
>
> The trick is to multiply everything up by 100 so that you're working in
> pence, cents, or whatever currency you're dealing with. Then do your
> monthly interest multiplication forced to INT and then divide you're
> final answer by 100 to get back you're 2 dec. points.
>
> Chris.
>
Please excuse the piss-poor grammar. The last two "you're"s should be
"your".
------------------------------
Date: Fri, 1 Aug 2003 23:17:06 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: question from perl noob
Message-Id: <bgdi4p$neq2s$1@ID-172104.news.uni-berlin.de>
"boblehue" <boblehue@online.no> wrote in message
news:NdpWa.17188$Hb.287897@news4.e.nsc.no...
[snipped repeated question in alt.perl]
Please read http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
------------------------------
Date: Fri, 01 Aug 2003 10:21:37 +0100
From: Chris <no_thanks@bms.umist.ac.uk>
Subject: Re: Substitution Question
Message-Id: <3f2a3b5f$1@news.umist.ac.uk>
John W. Krahn wrote:
> Janek Schleicher wrote:
>
>>Mike Flannigan wrote at Thu, 31 Jul 2003 21:15:39 +0000:
>>
>>>I simply want to convert Adkins to Adki01
>>>
>>>This code is close, but has a space between
>>>Adki and 01
>>>
>>>$temp =~ s/^(.{0,4})..$/$1 01/;
>>
>>If you want substitute characters defined in their absolute positions, the
>>substr function might be your friend:
>>
>>substr($temp,4,2) = "01";
>
>
> You can leave out the length argument if you want to substitute the rest
> of the string at position 4.
>
> substr( $temp, 4 ) = '01';
>
>
> John
or even
substr($temp, 4, 2, '01');
Chris.
------------------------------
Date: Fri, 01 Aug 2003 12:58:36 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Substitution Question
Message-Id: <3F2A6483.8B73CBB0@earthlink.net>
"John W. Krahn" wrote:
> You can leave out the length argument if you want to substitute the rest
> of the string at position 4.
>
> substr( $temp, 4 ) = '01';
OK, as is often the case with posters, I lied a little bit.
I need the length argument because not all the lines I am
changing are 4 characters long. If they are 4, 5 or 6
characters I want:
Adki01
3 characters:
Aki01
2 characters:
Ak01
etc.
I just figured out that substr ($temp, 4, 2, "01");
returns an error if the field is less than 4 characters.
"substr outside of string . . . "
After I do some cleanup I'll post my code - partly
just to give you guys a good laugh :-)
Mike
------------------------------
Date: Fri, 1 Aug 2003 08:41:11 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: using post method
Message-Id: <slrnbikrfn.42c.tadmc@magna.augustmail.com>
hash <hash_q@yahoo.com> wrote:
> Eric Schwartz <emschwar@ldl.fc.hp.com> wrote in message news:<etod6fq8f64.fsf@wormtongue.emschwar>...
>> "Dave Millen" <postmaster@[127.0.0.1]> writes:
>> > The form handler will be checking the HTTP_REFERER value and rejecting
>> > anything that doesn't come from the expected page.
>>
>> s/come from/claim to $&/
>
> what does the above line mean?
---------------------------------
#!/usr/bin/perl
use strict;
use warnings;
$_ = "rejecting anything that doesn't come from the expected page\n";
print "before: $_";
s/come from/claim to $&/;
print "after: $_";
---------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 01 Aug 2003 11:26:33 +0100
From: Stephen <usenet_removebeforesending_@fatkoala.co.uk>
Subject: Wait for directory changes in Windows XP?
Message-Id: <8lfkiv850jm82aboa14c4j6ovoqp35mf16@4ax.com>
I am trying to write a Perl script that will watch a directory for MP2
files created by some TV recording software, then trigger some other
actions on each file that is created (eg convert them into MP3).
I have looked at ChangeNotify and AdvNotify. However, I think both of
these will trigger action as soon as the recording software STARTS writing
a file.
I want to trigger action when it has FINISHED writing the file.
In an Explorer window can see the file get opened and progressively growing
during the recording. There is no published API to lock the file, etc.
Any suggestions?
------------------------------
Date: Fri, 01 Aug 2003 12:41:06 +0100
From: jimbo <jimbo@soundmiges.co.uk>
Subject: Re: Wait for directory changes in Windows XP?
Message-Id: <1059738043.847212@ananke.eclipse.net.uk>
Stephen wrote:
> In an Explorer window can see the file get opened and progressively growing
> during the recording. There is no published API to lock the file, etc.
Use flock() to try and gain an exclusive lock on the file. As long as
the file is in use by the other application you will be unable to get
the lock. After every change notify try and get the lock again.
You may find the lock is not released until the application which has
open the file exits, even after the file has been closed by the application.
here's a pl2bat test on a Win2K PC:
@rem = '--*-Perl-*--
@echo off
if "%OS%" == "Windows_NT" goto WinNT
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
:WinNT
perl -x -S %0 %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofperl
@rem ';
#!perl
#line 15
use strict;
use warnings;
use Fcntl qw(:flock);
open(FILE, "+< foo.txt") || die "cannot open foo.txt: $!\n";
warn "locking FILE: " . flock(FILE, LOCK_EX | LOCK_NB);
open(TEST, "+< foo.txt") || die "cannot open foo.txt: $!\n";
warn "locking TEST: " . flock(TEST, LOCK_EX | LOCK_NB);
warn "unlocking FILE: " . flock(FILE, LOCK_UN);
warn "locking TEST: " . flock(TEST, LOCK_EX | LOCK_NB);
warn "locking FILE: " . flock(FILE, LOCK_EX | LOCK_NB);
__END__
:endofperl
which outputs:
locking FILE: 1 at flock.cmd line 21.
locking TEST: 0 at flock.cmd line 24.
unlocking FILE: 1 at flock.cmd line 26.
locking TEST: 1 at flock.cmd line 27.
locking FILE: 0 at flock.cmd line 28.
jimbo
;-)
------------------------------
Date: Fri, 01 Aug 2003 14:14:45 +0100
From: Garry Heaton <none@none.com>
Subject: Re: Web development and Perl 6
Message-Id: <JNtWa.52043$9C6.3025454@wards.force9.net>
Thanks Tassilo. At lesat someone has grasped my original point.
Garry Heaton
Tassilo v. Parseval wrote:
> Also sprach Uri Guttman:
>
>
>>>>>>>"GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
>>
>> GH> The point I was trying to make is:
>> GH> - Some people in this group seem to believe it is good for Perl if
>> GH> "newbies" opt for PHP before Perl/CGI for web scripting.
>> GH> - I expressed my doubts about that view.
>>
>>more like it doesn't matter to perl what they choose for web stuff since
>>web stuff is a fraction of the entire perl world. just wait until the
>>newbies do something real and try to use php for genomics or parsing.
>>
>>the point is not to fret over what people use for web apps. it is
>>nothing compared to the large picture.
>
>
> Yet, the web is a good entrance point for a programming language. When I
> started with Perl it was because I wanted to do some CGI stuff. The
> interesting thing is that I soon started to use Perl for all other
> things _but_ CGI (not because Perl would be unsuitable for that but
> because I got bored by CGI-thingies).
>
> For me the question remains what my primary language would be right now
> hadn't Perl had the reputation to be a web-language. Perhaps I'd be
> programming PHP or Java now (and be less happy).
>
> In essence, the assumption that a person starting his life as CGI
> script-kiddie will remain one till the end of his days is wrong. He
> might soon switch to more interesting domains and even become a
> CPAN-author or perl5/6-porter or whatever. Or become a knowledgeable
> regular in clpm. Go figure.
>
> The point of the OP was - as far as I understand it - not to alter Perl
> in order to attract the kiddies. It was to provide a homogeneous Perl
> environment so that webhosts are encouraged to offer a solid mod_perl
> system. Would that be hard? No, not so:
>
> perl (standard distribution or perhaps stripped down)
> mod_perl
> DBI
> DBD::mysql
> libnet
> libwww
> some HTML/XML modules
> CGI
> EmbPerl (to make it 'appear' more PHPish)
>
> Bundle that up, provide an installation script and some documentation.
> And give it a flashy name so that people start to recognize it by that
> (like PerlWDK or so).
>
> Even from a selfish point of view, that wouldn't be so bad. I might some
> day be in the situation where I have use for a good webhoster. I am sure
> I'll get very sick if all I have is some mod_php crap.
>
> So all that remains to be done is take those things that already exist
> and bring them together in a fairly standardized way and seamless way.
>
> Tassilo
------------------------------
Date: Fri, 1 Aug 2003 09:14:42 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Web development and Perl 6
Message-Id: <bgdspa$6r3$1@slb4.atl.mindspring.net>
"Keith Keller" <kkeller-spammmm@wombat.san-francisco.ca.us> wrote in message
news:inrcgb.hle.ln@goaway.wombat.san-francisco.ca.us...
<snip>
> If the mailing address for ''Billyray'' is accurate, she
> may not be a good source for those seeking knowledge on
> any subject, though asses might just be up her alley.
>
> Time to adjust your scorefiles, kids!
Apologies for adding to off-topic noise, folks.
Clearly, Randal needs no defense.
Bill Segraves
------------------------------
Date: Fri, 01 Aug 2003 14:25:59 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Web development and Perl 6
Message-Id: <87n0ettq3q.fsf@mithril.chromatico.net>
Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> Charlton Wilbur wrote:
> > The reason Perl made such great inroads is that Perl has a rich set
> > of string manipulation tools available. So long as Perl continues
> > to have a rich set of tools available, it will continue to be
> > useful. If it becomes less relevant to clueless web newbies, so
> > much the better.
>
> Err.. I suppose that you started your programming career as a clueless
> newbie, too. Didn't we all? (Some would say that I'm still there, btw.)
Yes; but at that time there was no web in common usage, and I wasn't
arguing to seasoned programmers that all programming languages should
be completely accessible to clueless web newbies, and neither was I
under the delusion that a book on a popular language would make me
anything BUT a clueless newbie with a book in his hand. This,
perhaps, makes me substantially less clueless than the average
clueless web newbie.
Charlton
------------------------------
Date: Fri, 01 Aug 2003 14:40:57 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Web development and Perl 6
Message-Id: <87isphtpqf.fsf@mithril.chromatico.net>
Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> Personally I believe that any program needs a big user base, and
> through the web, you reach a big audience.
Why? Perl needs to maintain a Perl-development group at least as big
as it is now, but except insofar as the size of the user base affects
the size of the development group, the size of the user base is
irrelevant. Perl is there for me to use, whether 100 million other
people are using it or only 25.
> Sometimes I feel that regulars in this group deliberately and
> actively discourage Perl and CGI from being used for trivial web
> scripting, and _that_ amazes _me_. I smell snobbery.
CGI scripting is terribly easy. There are perhaps five hard problems
specific to it, and they have all been solved, and they are all
well-documented at the level a competent novice can understand. When
someone has a persistent problem with one of them, it is either
because of an unwillingness or inability to read the documentation
once pointed out, or a problem with a fundamental aspect of
programming or Perl. In neither of these cases is an exchange on
Usenet likely to be all that helpful.
Charlton
------------------------------
Date: Fri, 01 Aug 2003 15:58:09 +0100
From: Garry Heaton <none@none.com>
Subject: Re: Web development and Perl 6
Message-Id: <EivWa.52059$9C6.3027306@wards.force9.net>
It appears I drifted into the wrong newsgroup. Perhaps I should have
searched for comp.lang.perlforcluelessnewbies as most of the respondents
here are more interested in distancing themselves from web developers who,
by definition, seem to be tarred as "clueless". I give up.
Garry Heaton
Charlton Wilbur wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
>
>
>>Charlton Wilbur wrote:
>>
>>>The reason Perl made such great inroads is that Perl has a rich set
>>>of string manipulation tools available. So long as Perl continues
>>>to have a rich set of tools available, it will continue to be
>>>useful. If it becomes less relevant to clueless web newbies, so
>>>much the better.
>>
>>Err.. I suppose that you started your programming career as a clueless
>>newbie, too. Didn't we all? (Some would say that I'm still there, btw.)
>
>
> Yes; but at that time there was no web in common usage, and I wasn't
> arguing to seasoned programmers that all programming languages should
> be completely accessible to clueless web newbies, and neither was I
> under the delusion that a book on a popular language would make me
> anything BUT a clueless newbie with a book in his hand. This,
> perhaps, makes me substantially less clueless than the average
> clueless web newbie.
>
> Charlton
>
------------------------------
Date: Fri, 1 Aug 2003 23:14:24 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: Web page with frames...
Message-Id: <bgdhvn$mh84m$1@ID-172104.news.uni-berlin.de>
"mgarrish" <mgarrish@rogers.com> wrote in message
news:bziWa.34192$hOa.28630@news02.bloor.is.net.cable.rogers.com...
>
> "Eric Schwartz" <emschwar@ldl.fc.hp.com> wrote in message
> news:eton0eua93o.fsf@wormtongue.emschwar...
> >
> > Yes, people do a lot of things with Perl; that doesn't make questions
> > about them Perl questions. I'm writing a library-cataloguing system
> > in Perl right now; does that make comp.lang.perl.misc a good place to
> > ask if I should use Library of Congress or Dewey-Decimal indexing?
> > (In the short term, probably LoC, only because I can easily query
> > their database using Net::Z3950, but I'd like to offer both.)
> >
>
> And a lot of people offer that same incredibly trite answer, which is
> equally pointless. For one, the offenders obviously don't know where they
> should be posting, so being a prick does nothing but make yourself look
like
> a moron. Second, it's not going to change anything; the people who post
> off-topic questions are usually the ones who have never looked for the
> answer. And finally, it does nothing to help the poster find his way to
> where he should be posting. (And I'm referring more to the resident
jackass
> in this group who posted the earlier reply.) If you don't like off-topic
> posts, stick to a moderated group...
>
> Matt
> (who eagerly awaits the day someone creates a way to send an e-slap)
The one thing you are forgetting are all the Usenet archives like Google
Groups. Having the so called "trite answers" at least helps some newbies in
the future how have the common decency to search before they post.
------------------------------
Date: Fri, 1 Aug 2003 14:27:39 +0000 (UTC)
From: "W K" <hyagillot@tesco.net>
Subject: Re: win32 - kill 0 and handle leaks.
Message-Id: <bgdtcr$e2h$1@hercules.btinternet.com>
"Sisyphus" <kalinabears@iinet.net.au> wrote in message
news:3f29c950$0$23613$5a62ac22@freenews.iinet.net.au...
>
> "W K" <hyagillot@tesco.net> wrote in message
> news:bgatab$b1a$1@titan.btinternet.com...
> > I have a process that needs to check pids of other processes on win2000.
> >
> > However, whenever when I do a kill 0, $pid - the number of handles (seen
> in
> > task manager) goes up by one.
<snip>
> Afaict, you're doing nothing wrong - and when I run your script I see
> precisely what you're seeing (with both perl 5.6.1 and 5.8.0).
>
> I can't find any documentation warning of this behaviour and I can't find
> any way of clearing those handles without having the script exit.
Thank you. I'm not insane then.
> (Just stop and re-start the checking process
> every-so-often :-)
well, I'd got 50 day's worth at 4/minute.
> Alternatively you can probably achieve what you're after with one of the
> Win32 modules. Win32::PerfLib ( http://www.bybyte.de/jmk/Perl5.asp )
should
> accommodate your needs, or Win32::Process::Info (from cpan) might also do
> it.
Yes, I have gone for the latter can get a list of pids, which fits much the
same purpose as testing with "kill 0".
Of course, it can also tell you much more about the processes so should be
more useful, should I chose to extend the functionality.
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5305
***************************************