[18083] in Perl-Users-Digest
Perl-Users Digest, Issue: 243 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 8 14:06:08 2001
Date: Thu, 8 Feb 2001 11:05:32 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981659131-v10-i243@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 8 Feb 2001 Volume: 10 Number: 243
Today's topics:
Re: "Average of List of Numbers" by Abigail <mischief@velma.motion.net>
(OFF TOPIC) Re: This is driving me nuts and I need a gu <godzilla@stomp.stomp.tokyo>
Re: alt.perl and correctness (was Re: hex to binary con <mischief@velma.motion.net>
Re: alt.perl and correctness (was Re: hex to binary con (Randal L. Schwartz)
Re: Big Numbers nobull@mail.com
Bizzare behaviour of perl when forked a lot <dpc29@sheetmusic.org.uk>
Re: CGI B-A-S-I-C-S? <jbroz@transarc.ibm.com>
Re: CGI B-A-S-I-C-S? <m_ario@my-deja.com>
Re: CGI.pm image upload probs <fty@mediapulse.com>
Re: CGI.pm image upload probs <idontreadthis56@hotmail.com>
Re: CGI.pm image upload probs nobull@mail.com
Re: CGI.pm image upload probs nobull@mail.com
Changing Share Permissions: Win32::NetResource::NetShar <rckjr@yahoo.com>
Counter script problems <martin@nospam.pebblenet.co.uk>
CPAN for win32 <kliquori@my-deja.com>
Re: CPAN for win32 mike_solomon@lineone.net
Re: CPAN for win32 <mothra@nowhereatall.com>
Re: Devel DProf and " dprofpp " <amonotod@netscape.net>
Re: don't want to let them enter & and = ... <emelin@my-deja.com>
Re: don't want to let them enter & and = ... (Randal L. Schwartz)
Re: don't want to let them enter & and = ... <bart.lateur@skynet.be>
Editing a file if line doesn't exist already jstanley@mmm.com
File update works under Linux, not under Solaris. Any i <frankvw@euronet.nl>
getting date from Week number mike_solomon@lineone.net
Re: Grep error in Perl program... <ncheung@draper.com>
Help Installing Crypt::SSLeay ryanblock@my-deja.com
Re: help with multiple if statements ? (Mark Jason Dominus)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 08 Feb 2001 16:33:58 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: "Average of List of Numbers" by Abigail
Message-Id: <t85ijmhf4dle12@corp.supernews.com>
In comp.lang.perl.misc Monte Phillips <montep@hal-pc.org> wrote:
> On Wed, 07 Feb 2001 16:10:37 -0000, Chris Stith >
>>>Monte wrote--> Elegance in all matters, whether mathematical, musical, visual or
>>> anything else is simply this(pun intended<grin>):
>>
>>> The shortest line between two points!
>>
>>> HERE:route:OBJECTIVE
>>>
>>>Monte,
>>>
>>I suppose posting the same message three times is the shortest
>>line to making your point? ;)
> I have no idea why or how that got repeated.
Notice the winky smiley face. News glitches happen. I understand.
[snip]
> Beauty is in the eye of the beholder. Elegance being linguistically
> related to beauty holds a similar definition. You are quibbling.
> Just as in art, when Perl or any other program appears 'elegant' it
> is. If it does not appear so, then it isn't. Remember, beautiful
> ladies come in many different packages. Why do you think Larry gave
> this language a womens name?<grin>
True, it is in the eye of the beholder, and in my eye, I tend to
behold things at face dictionary value. You are quibbling about my
reasoning when I do so.
> Secondly most of the factors you list are inter-related and so when
> one is optimized the others follow. Optimizing one does not optimize
> the others necessarily, but if you program enough years you will know
> that the others become weighted automagically as a result of
> optimizing the prime factor that tickles your fancy and suits the
> projects goals.
I take this as an ad hominem attack. You do not know how many years
I have been programming. Besides, programming something the shortest
way in source code doesn't even necessarily correspond to the fewest
object bytes - especially in a high-level language. Source size,
object size, speed, and low memory use do not naturally follow one
another. Often it is necessary if you need the most speed that you
give up memory efficiency and object code size - sometimes source
code size as well. My "prime factors" usually are working code,
meeting deadlines, and maintainability. I only worry about other
factors as they become hotspots or as I'm bored at home on a hobby
project.
Chris
--
Christopher E. Stith
Where there's a will, there's a lawyer.
------------------------------
Date: Thu, 08 Feb 2001 10:23:44 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: (OFF TOPIC) Re: This is driving me nuts and I need a guru
Message-Id: <3A82E430.983B8699@stomp.stomp.tokyo>
"Randal L. Schwartz" wrote:
> >>>>> Peter wrote:
> Peter > As much as I admire and respect the denizens of this NG I have noted
(snipped comments worthy of read)
> The net is ripping at the seams, it seems. I won't go so far as to
> say "imminent death of the net predicted, film at 11", because I've
> seen that phrase used far too often. But it's gonna have to get
> different about how people interact with each other here for it to
> scale bigger.
You are Randal L. Schwartz of Oregon. I am Kiralynne Schilitubi
of Southern California. I know where you live, you know where
I live, we both know where are our respective homepage sites,
our email addresses and similar information.
This knowledge above, is quite rare, as you know Randal.
One of a number of fundamental problems with our new frontier,
our internet, is anonymity; our right to privacy. This, among
our other 'inherent rights' must be protected. However, this
right to privacy, this anonymity, is a gateway for abuse.
Here within our internet, anonymity leads to significant abuse
of our internet society at large. Avoiding a lengthy and prone
to controversy discussion of the dark side of human nature,
our internet provides an 'open season' on everyone; abuse by
those too cowardly to perpetrate this type of abuse, publically,
out 'there' in the so called real world. These people are those
I think of as, Keyboard Cowards.
Our Perl group here, is a slice of this larger problem. Our Perl
group well exemplifies how people, each looking to satiate her
or his unhealthy ego, will abuse others without hesitation. Some
take this activity to a psychotic level. This I know too well.
As an example, here in our group, there is one person, a rather
mentally and emotionally unstable person, pretending to be,
quite literally, hundreds of different people, each 'person'
posting pretend problems with an intent of initiating argument,
with an intent of ego satiation by responding to himself with
solutions and intent to make himself appear intelligent to
others, those others fooled by this impotent con game.
No need to discuss truly criminal activities here within our
internet; we all know of those.
There are those leaning towards technological methods of
absolute identity of people using our internet, a driver's
license, fingerprints, so to speak. I am one of those people.
My hopes are, in time, technology will provide a method of
'stamping' each computer with an identity which will protect
our right to privacy yet provide a quick and certain method
to identify those perpetrating abuse upon others.
Someday, abusive people will be put in a position of knowing,
"There is a very good chance I will be caught and punished."
When this day comes, ironically our new frontier, our internet,
will lose its wildness, just as our Wild West did. This is a
given and I hope this day will arrive soon, with some regrets.
Godzilla!
------------------------------
Date: Thu, 08 Feb 2001 17:11:15 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: alt.perl and correctness (was Re: hex to binary conversion ? Please help)
Message-Id: <t85kpjh340b769@corp.supernews.com>
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Abigail" == Abigail <abigail@foad.org> writes:
> Abigail> Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMDCCXVIII September
> Abigail> MCMXCIII in <URL:news:m1vgqlqs8c.fsf_-_@halfdome.holdit.com>:
> Abigail> ()
> Abigail> () I'd rather alt.perl go away. But since it's here... I guess it'll be
> Abigail> () in my subscribe list.
> Abigail> Then you are actively keeping it alive. After all, if lots of people
> Abigail> answer questions in both groups, there's no initiative to move to
> Abigail> clp.misc.
> No, call it karma, but if I let questions get answered badly there,
> it'll be just my luck that one of those incorrect answers will be used
> to make a crap website somewhere that leaks my credit card number or
> keeps me from finding out about a good deal or something.
On the other hand, the more crap websites are made that barely work,
the more marketable a real guru such as Randal becomes. I'm sure
he's at least considered that possibility, though.
Back on the first hand again... many companies would rather pay $20
per hour for ten hours and get mediocre but mostly working code than pay
$150 per hour for one hour and get good, solid code.
Chris
--
Christopher E. Stith
Programming is a tool. A tool is neither good nor evil. It is
the user who determines how it is used and to what ends.
------------------------------
Date: 08 Feb 2001 09:29:58 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: alt.perl and correctness (was Re: hex to binary conversion ? Please help)
Message-Id: <m166ilnkvd.fsf@halfdome.holdit.com>
>>>>> "Chris" == Chris Stith <mischief@velma.motion.net> writes:
Chris> On the other hand, the more crap websites are made that barely work,
Chris> the more marketable a real guru such as Randal becomes. I'm sure
Chris> he's at least considered that possibility, though.
I'm trying to work my way *out* of a job, not *into* one. There's not
enough people like me to go around. :)
Chris> Back on the first hand again... many companies would rather pay
Chris> $20 per hour for ten hours and get mediocre but mostly working
Chris> code than pay $150 per hour for one hour and get good, solid
Chris> code.
Ain't that the truth! And most of the hacked pages out there show it.
("hacked" in both the good and evil meanings.)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 08 Feb 2001 17:41:38 +0000
From: nobull@mail.com
Subject: Re: Big Numbers
Message-Id: <u9itmlysvh.fsf@wcl-l.bham.ac.uk>
Slasia <skorpik@yoyo.pl> writes:
[ I need big integers ]
Look on CPAN for a module that implements big integers.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 8 Feb 2001 14:05:17 +0000
From: David Chan <dpc29@sheetmusic.org.uk>
Subject: Bizzare behaviour of perl when forked a lot
Message-Id: <Pine.SOL.4.21.0102081354520.15027-100000@yellow.csi.cam.ac.uk>
Hi,
This is not a fork bomb.
When I try the following on my (P200, Linux 2.2.14) computer, using perl
5.005.03:
$ perl -e 'fork||print for split//,"abcdefghij"'
The output, as well as having lots of jumbled lettes a..j like you'd
expect, has the number 1 in it many times. It doesn't happen if I do:
$ perl -e 'fork||print for "a" .. "j"'
But when I try it out on a (PII, Linux 2.0.3x) college computer, the 1's
appear in *both* instances. When I try it on an alpha running perl 5.003,
it complains a lot like this: "Unable to obtain requested swap space".
The alpha's exact spec is as follows:
> ================================================================
> chasm.amtp.cam.ac.uk AlphaStation 200 4/166 system
> Digital UNIX V4.0F Memory 80 Mb (72 avail), Swap 124 Mb
> ================================================================
Is this weird behaviour due to something silently failing when thousands
of copies of a process are running at once?
Many thanks,
David
--
Lbh unir gbb zhpu serr gvzr.
------------------------------
Date: Thu, 08 Feb 2001 16:31:54 +0000
From: Joe Broz <jbroz@transarc.ibm.com>
Subject: Re: CGI B-A-S-I-C-S?
Message-Id: <3A82C9FA.B0CDB237@transarc.ibm.com>
nobull@mail.com wrote:
>
> Fatboy <creator@itsallok.nl> writes:
>
> > Can anybody show me where to pick up the total basics?
>
> The "SYNOPSIS" section of perldoc CGI
Also, this is more appropriate for comp.lang.perl.modules
------------------------------
Date: Thu, 08 Feb 2001 18:50:49 GMT
From: Mario <m_ario@my-deja.com>
Subject: Re: CGI B-A-S-I-C-S?
Message-Id: <95upq5$6lg$1@nnrp1.deja.com>
In article <3A81733C.2320AE61@itsallok.nl>,
Fatboy <creator@itsallok.nl> wrote:
> I'm quite handy with Flash-actionscripting but a complete dummy in
> CGI-writing.
> I'd like to send variables from flash and write it in a txt-file. And
> use a CGI-script to do all this.
>
> I know it must be simple, but I hardly know anything when it comes to
> writing in Perl.
> Can anybody show me where to pick up the total basics?
"Learning Perl - 2nd Edition" from O'Really.
--
Mario
diab.litoATusa.net
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 08 Feb 2001 16:05:13 GMT
From: "Jay Flaherty" <fty@mediapulse.com>
Subject: Re: CGI.pm image upload probs
Message-Id: <Zszg6.163756$Df2.11307056@news3.aus1.giganews.com>
<todd@designsouth.net> wrote in message news:95tgj0$2p1$1@nnrp1.deja.com...
> I can get a file to upload, and I use the binary file code as specified
> by the CGI docs:
>
> $f = $cgi->param("image");
> open (O,">../images/pics/$uid/$pic_id.jpg");
> while ($bytesread=read($f,$buffer,1024)) {
> print O $buffer;
> }
try using tmpFileName()
my $file = $cgi->param('image');
my $temp = $cgi->tmpFileName($file);
rename $temp, "./uploaded.jpg";
jay
------------------------------
Date: Thu, 08 Feb 2001 11:21:58 -0600
From: Keep it to Usenet please <idontreadthis56@hotmail.com>
Subject: Re: CGI.pm image upload probs
Message-Id: <idontreadthis56-0BCC7E.11215808022001@[216.227.56.89]>
In article <Zszg6.163756$Df2.11307056@news3.aus1.giganews.com>, "Jay
Flaherty" <fty@mediapulse.com> wrote:
> try using tmpFileName()
>
> my $file = $cgi->param('image');
> my $temp = $cgi->tmpFileName($file);
> rename $temp, "./uploaded.jpg";
My fear about this is that tmpFileName is an "undocumented" portion of
the API. It could disappear with the next release. Has anybody
looked at the 3.0 version to see if it's still included?
--
Help! I'm being held in a .sig factory.
------------------------------
Date: 08 Feb 2001 17:46:10 +0000
From: nobull@mail.com
Subject: Re: CGI.pm image upload probs
Message-Id: <u9elx9ysnx.fsf@wcl-l.bham.ac.uk>
todd@designsouth.net writes:
> I can get a file to upload, and I use the binary file code as specified
> by the CGI docs:
>
> $f = $cgi->param("image");
> open (O,">../images/pics/$uid/$pic_id.jpg");
> while ($bytesread=read($f,$buffer,1024)) {
> print O $buffer;
> }
binmode(O) is missing.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 08 Feb 2001 17:48:21 +0000
From: nobull@mail.com
Subject: Re: CGI.pm image upload probs
Message-Id: <u9bssdyska.fsf@wcl-l.bham.ac.uk>
"Jay Flaherty" <fty@mediapulse.com> writes:
> my $file = $cgi->param('image');
> my $temp = $cgi->tmpFileName($file);
> rename $temp, "./uploaded.jpg";
This is very efficient if it works, but it won't often work because
the temporary file will usually be on a different disk from the
current directory.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 08 Feb 2001 18:03:06 GMT
From: Dr. Strangepork <rckjr@yahoo.com>
Subject: Changing Share Permissions: Win32::NetResource::NetShareSetInfo or Not?
Message-Id: <95un0h$3s4$1@nnrp1.deja.com>
I am hoping beyond hope that someone can help me here. I've even seen
a post recently from Dave Roth questioning whether this function works
or not. I have not been able to get it to work. Consider the
following code:
$ShareName = "Temp"; # This is an existing share
$ShareInfo = {
'path' => "C:\\temp",
'netname' => "Temp Perl Share",
'remark' => "It is good to share",
'passwd' => "",
'current-users' =>0,
'permissions' => 0,
'maxusers' => -1,
'type' => 0,
};
unless(Win32::NetResource::NetShareSetInfo($ShareName,\%
ShareInfo,$parm)) {
Win32::NetResource::GetError($err);
warn Win32::FormatMessage($err);
}
I get the error message "The parameter is incorrect." back from this
code, but I do not see what I am doing wrong. Can someone correct me?
Or if someone can confirm that the NetShareSetInfo() function does not
work, can someone explain how to change share permissions (and other
features) using Perl?
--
Rick Kasten, MCSE SysAdmin Consultant
Collective Technologies http://www.colltech.com
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 8 Feb 2001 15:00:50 -0000
From: "Martin J. Stone" <martin@nospam.pebblenet.co.uk>
Subject: Counter script problems
Message-Id: <95ucdf$8mu$1@plutonium.btinternet.com>
I can't get a basic counter script to function on a Windows 2000 IIS5 server
with ActiveState Perl installed. No errors are reported by the server, the
counter file is not incremented and no counter is displayed.
Other scripts (current date displayed) work fine so no issues with Perl in
general and enabling SSI (.shtml).
The basic counter script is:
==============================
$pagepath = $ENV{'DOCUMENT_URI'};
print "Content-type: text/html\n\n";
open(FILE, ">>$counter_file");
close(FILE);
open(FILE, "$counter_file");
@indata = <FILE>;
close(FILE);
$onoff = 0;
open(FILE, ">$counter_file");
foreach $temp (@indata)
{
chop($temp);
($uri, $count) = split(/\|/, $temp);
if ($uri eq $pagepath) {
$count++;
$onoff = 1;
print FILE "$uri|$count\n";
print "$count"; }
else { print FILE "$uri|$count\n"; }
}
if ($onoff eq 0) {
print FILE "$pagepath|1\n";
print "1"; }
close(FILE);
================================
Any ideas?
Regards,
Martin...
------------------------------
Date: Thu, 08 Feb 2001 16:17:42 GMT
From: kliquori <kliquori@my-deja.com>
Subject: CPAN for win32
Message-Id: <95ugqr$tb6$1@nnrp1.deja.com>
Does anyone know if there's a CPAN.pm for ActiveState's Win32 distribution?
I've been having problems with ppm. I found documentation for CPAN.pm on
their site but cannot find the ppm module for CPAN.pm.
TIA
...Kevin
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 08 Feb 2001 16:20:50 GMT
From: mike_solomon@lineone.net
Subject: Re: CPAN for win32
Message-Id: <95uh0m$tmc$1@nnrp1.deja.com>
In article <95ugqr$tb6$1@nnrp1.deja.com>,
kliquori <kliquori@my-deja.com> wrote:
> Does anyone know if there's a CPAN.pm for ActiveState's Win32
distribution?
> I've been having problems with ppm. I found documentation for CPAN.pm
on
> their site but cannot find the ppm module for CPAN.pm.
>
> TIA
> ...Kevin
>
> Sent via Deja.com
> http://www.deja.com/
>
Kevin
try
http://www.activestate.com/PPMPackages/zips/6xx-builds-only/
Regards
Mike Solomon
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 08 Feb 2001 08:58:12 -0800
From: mothra <mothra@nowhereatall.com>
Subject: Re: CPAN for win32
Message-Id: <3A82D024.3264BAC9@nowhereatall.com>
kliquori wrote:
>
> Does anyone know if there's a CPAN.pm for ActiveState's Win32 distribution?
> I've been having problems with ppm. I found documentation for CPAN.pm on
> their site but cannot find the ppm module for CPAN.pm.
>
perl is distributed with the CPAN module included. To use it type
perl -MCPAN -e shell at the dos prompt. If it is the first time this is
run
you will be prompted for locations of utilities that is needed for the
module
to function correctly. Be warned, most of what is needed does not come
with the
windows product ( tar gzip ...) you will need to find and install these.
you
will also need nmake.exe. This is required to build many modules that
are located
in the CPAN resposortory.
I hope this helps.
Mothra!
------------------------------
Date: Thu, 08 Feb 2001 17:16:19 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Devel DProf and " dprofpp "
Message-Id: <95uk8o$t7$1@nnrp1.deja.com>
In article <x7itmlok4p.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
>
> G> I've figured out Devel DProf ok. It runs and
> G> produces a useless document, tmon.out .. whoopie.
>
> don't use those modules. they are meant to be used and share by people
> who don't want to or can't write their own. you obviously can write
> better code and don't need any prewritten stuff.
>
> G> What is dprofpp and how is it invoked and used?
>
> write your own. figure out how do to it all by yourself.
>
> G> Thanks, I think...
>
> you don't even know how to ask for help without conditions.
>
> go away and write all your own modules. don't try to use these. they
> require a brain and a sense of community and sharing. since don't have
> any of those, you cannot figure out how to use them. that is their
> secret key which you will never learn.
>
> uri
You know, you have managed to *exactly* convey my own sentiments while
reading the OP. Thank you, uri.
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 08 Feb 2001 14:11:29 GMT
From: emelin <emelin@my-deja.com>
Subject: Re: don't want to let them enter & and = ...
Message-Id: <95u9ec$m55$1@nnrp1.deja.com>
> your real problem is that you want to store userinput in a file
> delimited by a character that may exist in the input, in this
case '&'.
>
> a few solutions come to mind:
>
> a) use a different delimiter. for example the TAB character or
> some other that is impossible to be offered as input
>
> b) test for the existence of the character, and return an error if
found
>
> c) encode the input in some way before storing. there are many ways
> to do this, but if you are going to use CGI anyways, why not let it
> do it for you. I think the relevant functions are CGI::escape() and
> CGI::unescape()
Thank you very much, solution a) was nice and simple. :) Worked just
fine with tab instead (and the text file looks a lot nicer!).
Originally I was thinking about something like b), but I couldn't
figure out how to do this... so just out of curiosity, how can I test
for existence in this case... because I can't do it after the contents
have been received, split and stored into the hash (the &'s disappear
when you split...)... and well, before this is done I have nothing...
can't figure this one out!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 08 Feb 2001 06:35:51 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: don't want to let them enter & and = ...
Message-Id: <m1g0hpp7i0.fsf@halfdome.holdit.com>
>>>>> "emelin" == emelin <emelin@my-deja.com> writes:
emelin> Thank you very much, solution a) was nice and simple. :)
emelin> Worked just fine with tab instead (and the text file looks a
emelin> lot nicer!).
Of course, this will break the moment someone sends you a TAB as part
of their data (which is completely possible, as the FORM input spec
is 8-bit clean).
You really need to bump up to a reversible-encoding scheme of some kind.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Thu, 08 Feb 2001 16:30:33 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: don't want to let them enter & and = ...
Message-Id: <adi58t8ghoc5rj61lgq42it5oqvib25tv0@4ax.com>
emelin wrote:
>> b) test for the existence of the character, and return an error if
>found
>Originally I was thinking about something like b), but I couldn't
>figure out how to do this... so just out of curiosity, how can I test
>for existence in this case...
tr/&//d;
That gets rid of it. If you like, you can get the count of how many were
deleted, by taking the return value of tr///.
--
Bart.
------------------------------
Date: Thu, 8 Feb 2001 10:30:36 -0600
From: jstanley@mmm.com
Subject: Editing a file if line doesn't exist already
Message-Id: <95uhjd$296$1@magnum.mmm.com>
I am having trouble thinking of a way to edit a file only if a particular
line doesn't exist.
I am using the following. I need to be able to read through a file and look
for a particular line. If that line is not found then it should be added to
the end of the file. Unfortunately the way I am doing it now, the WHILE
statement checks each line in the file and adds test to the bottom of the
file for everytime it doesn't find a match. I only want it to add a line at
the bottom if it doesn't find a match after going through the whole file.
open (LAST, "\\\\$server\\c\$\\directory\\subdir\\dat\\1\\file.cfg") || die
"Cannot append to last.cfg\n";
while (defined <LAST>) {
if (/text to match/i) {
print "Match exists\n";
}else {
Add line to file Code.......
Opinions expressed herein are my own and may not represent those of my employer.
------------------------------
Date: Thu, 08 Feb 2001 19:38:22 +0100
From: Frank van Wensveen <frankvw@euronet.nl>
Subject: File update works under Linux, not under Solaris. Any ideas?
Message-Id: <r5p58tk2crh80474kj4ur3acag19erd6dh@4ax.com>
Could someone take a look at the following? It really has me up the
wall. All help would be appreciated.
I have a file (which I call an extract file because it contains
records with web page summaries) that consists of single-line records.
Records are basically \n-terminated lines of ASCII text, fields are
separated by a "%%==%%" string.
I open this file for appending (+<$filename) and read it line by line,
check for certain conditions, and if necessary I modify the record (by
changing an ASCII 0 to ASCII 1, the record length stays the same),
rewind to the start of record offset in the file, and write it back.
Note: the first line of the file contains only a Unix timestamp for
later version management.
This works perfectly under Linux. Under Solaris, I rewind to the
appropriate file offset (I've checked that by inserting debug code)
but more data is written back than just the record; instead of just
one line, several lines are added. These contain fragments of other
records, apparently it's left-over buffer data or something. This also
happens when the last line is being written back, so the loop never
reaches end of file. (You will eventually reach the end of your free
disk space though.)
What has me stumped is that this works perfectly under Linux but not
under Solaris (using the same data files).
Here's the code:
#!/usr/bin/perl -w
open (EXTRACT, "+<$extractfile") || die ("Error\n"); # Open/append
seek (EXTRACT, 0, 0); # Rewind
$lasttime = <EXTRACT>; # Read last timestamp
extractcleanup (); # THIS GOES WRONG
# At this point other things are done to append new data
# (not relevant here, therefore removed)
$unixtime = time;
seek (EXTRACT, 0, 0); # Return to start of database
print EXTRACT "$unixtime\n"; # Save new timestamp
close (EXTRACT);
#
____________________________________________________________________________
# Go through the entire extracts table and flag pages that no longer
exist
# as 'expired'. The extracts database is supposed to be open.
sub extractcleanup {
my $extractrecord;
$foundcount = 0;
$expirecount = 0;
$savepos = tell (EXTRACT); # Save original file
position
seek (EXTRACT, 0, 0); # Rewind
my $firstline = <EXTRACT>; # Skip 1st line
(timestamp)
do {
my $startofrecord = tell (EXTRACT); # Save current record
offset
$extractrecord = <EXTRACT>; # Read current record
my ($expired, $path, $title, $description, $size, $last) =
split (/$delimiter/, $extractrecord); # Parse current record
unless ($expired) { # Ignore expired
entries
if (-e $path) {
$foundcount ++;
} else {
}
$expirecount ++;
$expired = 1; # Set expiry flag
$extractrecord = $expired . $delimiter . $path . $delimiter .
$title .
$delimiter . $description . $delimiter . $size . $delimiter
. $last;
seek (EXTRACT, $startofrecord, 0); # Rewind to start of
record
print EXTRACT "$extractrecord"; # Write back new
record
}
}
} until (eof (EXTRACT));
seek (EXTRACT, $savepos, 0); # Return to original
offset
}
Regards,
Frank
============================================
Email: frankvw@euronet.nl
Homepage: http://www.vanwensveen.nl
ICQ #: 13800170
============================================
------------------------------
Date: Thu, 08 Feb 2001 17:21:22 GMT
From: mike_solomon@lineone.net
Subject: getting date from Week number
Message-Id: <95uki5$1ap$1@nnrp1.deja.com>
Using Date::Calc I can get a Week number by providing a date
($week,$year) = Week_of_Year($year,$month,$day);
I want to provide the Week number and the Year and get the Week
Commencing date
So if I provide week 3 year 2001 I want to get back 15/01/2001
Does anyone have any idea how this could be done?
Thanks
Regards
Mike Solomon
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 08 Feb 2001 10:31:39 -0500
From: "Nicholas C. Cheung" <ncheung@draper.com>
Subject: Re: Grep error in Perl program...
Message-Id: <3A82BBDB.A78243F0@draper.com>
Anno Siegel wrote:
>
> Nicholas C. Cheung <ncheung@draper.com> wrote in comp.lang.perl.misc:
> >There was a time that this particular segment of code worked, but now,
> >it constantly gives me the following error message:
> >
> >grep: RE error 41: No remembered search string.
> >
> >Here is the segment of code which is the problem:
> >
> >open CHECK_PROG_RUN, "ps -e -opid,fname | grep \"$program\" |";
> >
> >Now I still want to pipe the output of that into the CHECK_PROG_RUN
> >filehandle, using grep or egrep, but various ways have failed, including
> >using ' and \' in place of \". With egrep (using egrep -e), it complains
> >of a syntax error.
> >
> >Are there any alternative ways of accomplishing this without the errors?
>
> Yes. Don't use an external program for selection, use a perl regex.
> That way you have quotemeta() (q.v.) to make your regex safe against
> unexpected meta-characters appearing in the program name.
>
> Anno
Anno,
I need to run an external program (ps) to find if a certain process is
running or not. Is there a perl equivalent for the Unix command ps?
Nick
------------------------------
Date: Thu, 08 Feb 2001 17:36:26 GMT
From: ryanblock@my-deja.com
Subject: Help Installing Crypt::SSLeay
Message-Id: <95ulep$26a$1@nnrp1.deja.com>
I am trying to install the Crypt::SSLeay module on our server that I
download from CPAN. However, when I run "make test", I get the
following error:
# make test
LD_RUN_PATH="/usr/local/ssl/lib" ld -
o ./blib/arch/auto/Crypt/SSLeay/SSLeay.sl -b -L/usr/local/lib
SSLeay.o -L/usr/
local/ssl/lib -lssl -lcrypto
ld: (Warning) At least one PA 2.0 object file (SSLeay.o) was detected.
The linked output may not run on a PA 1.x system.
ld: Invalid loader fixup for symbol "$002B0009".
*** Error exit code 1
Does anybody know how I could fix this and what is wrong with my
install?
BTW: I am trying to install this on an HPUX 10.20 system.
Much Thanks!!!
Ryan
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 08 Feb 2001 15:58:04 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: help with multiple if statements ?
Message-Id: <3a82c20c.57db$c7@news.op.net>
In article <95ru4h$ldr$1@nnrp1.deja.com>, <tvn007@my-deja.com> wrote:
>$name eq '&' if ($name == 0)
>$name eq '!' if ($name == 1)
>$name eq '#' if ($name == 2)
>$name eq '$' if ($name == 3)
>$name eq '%' if ($name == 4)
At the top of the program, use
@chars = ('&', '!', '#', '$', '%');
Then when you want to assign $name, use
$name = $chars[$name];
Note that '=' does an assignemnt. 'eq' does not.
--
@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: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 243
**************************************