[8245] in Perl-Users-Digest
Perl-Users Digest, Issue: 1862 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 11 17:07:24 1998
Date: Wed, 11 Feb 98 14:01:33 -0800
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, 11 Feb 1998 Volume: 8 Number: 1862
Today's topics:
Re: perl form problem <camerond@mail.uca.edu>
Re: perl form problem (Andrew M. Langmead)
Re: returning the date <Russell_Schulz@locutus.ofB.ORG>
Re: Syntax-coloring editor for NT <ldanna@hotmail.com>
Re: Syntax-coloring editor for NT <ldanna@hotmail.com>
Re: Text parsing <moc.care@hcajp - Reverse to get address>
Tied Hash File Size Limits?? <stevenjm@olywa.net>
Un crypt <Webmaster@eg-web.com>
Re: Un crypt (Mike Stok)
Re: Un crypt <tchrist@mox.perl.com>
Re: Un crypt (Nathan V. Patwardhan)
Re: Un crypt <dboorstein@shopcfn.com>
using undef (was Re: array question) (O'Shaughnessy Evans)
Re: Year 2000 Compliance: Lawyers, Liars, and Perl <swd@strata-group.Xcom>
Re: Year 2000 Compliance: Lawyers, Liars, and Perl <zooko@xs4all.nl>
Re: Yet Another Sorting Question(TM) <jdporter@min.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 11 Feb 1998 14:13:18 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: Brian Charles <charlesb@ccmail.orst.edu>
Subject: Re: perl form problem
Message-Id: <34E2065E.B84F5871@mail.uca.edu>
Brian Charles wrote:
>
> Hi,
> Can anyone look at the program below and tell me what's wrong.
Yes, you didn't open the file for writing, much less appending.
perldoc perlfunc See: open FILEHANDLE
Cameron Dorey
camerond@mail.uca.edu
------------------------------
Date: Wed, 11 Feb 1998 20:24:41 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: perl form problem
Message-Id: <Eo8E16.Dwt@world.std.com>
Brian Charles <charlesb@ccmail.orst.edu> writes:
>Hi,
> Can anyone look at the program below and tell me what's wrong. I'm a
>newbie to PERL. I want this program to take input (name and email) from
>a form and write it to a file which is then sorted and printed in html.
>The first part of the program isn't working. Data isn't being appended
>into the 'database' file from the form, but the data that is already in
>'database' is being printed to html just fine.
Well, as was pointed out elsewhere, the first problem was that you did
not set perl's warning messages on. (by using the "-w" switch.) This
would have told you about the second problem (in which you open a file
in read only mode and then attempt to write to it.)
Some would claim that the line 'require "cgi-lib.pl"' is an error. I'm
not sure I'd go that far, but you might want to heed the commonly
heard suggestion of taking a look at the CGI.pm module to if you might
want to use it instead.
I strongly disagree with anyone that would say that this is a question
that should be posted to a newsgroup that deals with CGI
questions. You're doing the CGI part correctly.
Unfortunately, you've gotten yourself in a project that involves some
issues that are beyond the novice level. You have concurrency issues,
for example. If you take a look at most programming tutorial books,
(for any programming language) you will not see synchronization
constructs explained early on. Many people may be nearly
simultaneously accessing a URL that causes the HTTP server to execute
your script. This means you may have more than one copy of your script
running at the same time. This could be disastrous when multiple
copies of your script try to write to the file at the same time.
Some material to discuss solutions to this problem are at
<URL:http://www.perl.com/CPAN/doc/manual/html/pod/perlfaq5/
How_can_I_lock_a_file_.html> and at <URL:http://www.stonehenge.com/
merlyn/WebTechniques/col04.html>
--
Andrew Langmead
------------------------------
Date: Wed, 11 Feb 1998 18:58:58 +0000
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: returning the date
Message-Id: <19980211.185858.1t7.rnr.w164w@locutus.ofB.ORG>
[ surely this isn't perl-specific anymore. ]
tchrist@mox.perl.com (Tom Christiansen) writes:
>> How about 1998-04-23 then? At least this can be easily used to sort
>> the names in chronological order...
>
> The problem, my dear Wolfgang, is that some of us don't automatically
> intuit 1998-03-04 or 03-04-1998 to be in either March or April.
that's why the ISO spelled it out for us. 1998-03-04 is in March.
except for 03-04-1998 -- nobody reasonable would use that, because
the meaning (if any) differs in different countries.
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Wed, 11 Feb 1998 15:08:54 -0500
From: Larry D'Anna <ldanna@hotmail.com>
Subject: Re: Syntax-coloring editor for NT
Message-Id: <34E20556.F8932EE0@hotmail.com>
scott@softbase.com wrote:
> I also maintain Microsoft is *NOT* a monopoly at all. They
> have a commanding share of the market because the alternatives
> are so awful. Microsoft has many rival Intel platform OSes:
> OS/2, Linux, Solaris, and more.
Microsoft has a monopoly of influence. If Microsoft says
something is standard then it is. This gives them a tremendous
advantage over other companies.
> > They use underhanded
> > legalisms, lies, marketing, and their unique position in the economy
> > to destroy any competitors that might dare to oppose them.
>
> I see this acusation a lot, but I have found very little evidence of
> it. Most of the times this is alleged, the competitior to Microsoft
> has done itself in through bad business decisions.
What do you call their attempt to make IE a part of their next release
of Windows?
> Some competitiors have actually shared their trade secrets with MS!
> Not smart. And then there's the case study of the fall of Lotus,
> a sad and pathetic story about how one of the best software
> houses was ruined.
Dear God! how could they be so stupid as to share knowledge with other
people. It is that kind of attitude that has put the software industry
into it's current pitiful state.
---------------------------------------------------
|Democracy is the worst system of government. --
|Except for all the others
| -Winston Churchill
---------------------------------------------------
Larry D'Anna "eschew obfuscation"
------------------------------
Date: Wed, 11 Feb 1998 15:16:56 -0500
From: Larry D'Anna <ldanna@hotmail.com>
Subject: Re: Syntax-coloring editor for NT
Message-Id: <34E20738.7F6EDC3@hotmail.com>
Andy Lester wrote:
> : There is a difference between the need to eat and the desire to get rich.
>
> So why didn't you just SAY that you disagree with capitalism? It would
> have saved a lot of time, not to mention the Internet Collective's
> bandwidth.
I don't disagree with capitalism. I disagree with the use of antiquated
copyright laws to prevent other people from sharing information in order
to force them to pay for software licenses.
---------------------------------------------------
|Democracy is the worst system of government. --
|Except for all the others
| -Winston Churchill
---------------------------------------------------
Larry D'Anna "eschew obfuscation"
------------------------------
Date: Wed, 11 Feb 1998 15:01:01 -0600
From: "Phil Jach - Reverse to get address" <moc.care@hcajp - Reverse to get address>
Subject: Re: Text parsing
Message-Id: <34e2119e.0@news1.ibm.net>
Is the information separated by comma, white space, tab, etc. Obviously
tabs would be hidden but you can still uses them to split data in a string
into an array. Let me know.
brian.russo@nextel.com wrote in message <887215449.44433418@dejanews.com>...
>Hello. I am attempting to write a perl script to read a log file (from
>a Nortel Switch) and parse out a couple different pieces of data. The
>log file is formatted in such a way that the headers and the data are
>seperated. For example:
>
>C7SCCP C7RTFALL C7RTFNTN C7RTFNTA C7RTFNWF C7RTFNWC C7RTFSS
>C7RTFSSC C7RTFUEQ C7UDTTX C7UDTTX2 C7UDTRX C7UDTRX C7UDTSTX
>C7UDTSRX C7MSGHDL C7MSGHD2 C7MSGGT C7MSGGT C7CLS0TX C7CLS0T2
>C7CLS0RX C7CLS0R2 C7CLS1TX C7CLS1T C7CLS1RX C7CLS1R2 C7SYNERR
>C7RTBKSS C7LOCSS C7LOCSS
>
> 0
> 24 0 2 0 0 2
> 0 0 6531 0 2101 0
> 1451 0 53540 0 1407 0
> 5928 0 669 0 603 0
> 1432 0 0 0 45532 0
>
>---------------------------------------------------------------------------
-
>
>So, my problem is, how can I parse the file and search for the begining
>of these stats and then save the numeric data in an array? These values
>exist in the log file 48 (every 30 minutes for 24 hours) seperate times
>and I would like to print out the results.
>
>Any help would be greatly appreciated,
>
>-Brian
>
>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 11 Feb 1998 12:56:15 -0800
From: Steven May <stevenjm@olywa.net>
Subject: Tied Hash File Size Limits??
Message-Id: <34E2106F.FB13040C@olywa.net>
Hello all,
I've been playing with tied hashes using SDBM. (SDBM since it's
available to anything that can run perl)
So. I've been building these simple little databases which seem to work
fine. I decided to see how big I could make one before something broke.
I wrote a little nested loop and generated 125,000 records of 22 fields
each to poke into my database system. I then started loading, testing
database response to inquiry every 1000 records.
The indexing system I've designed is primitive, but seemingly effective,
as I never did experieince any slowdown in accessing data.
BUT!
At 27,000+ records 550,000+ keys, the load script refused to load any
more records. I was doing all this nonsense on a win95 machine, and the
data.pag file had grown to just under 64 megs.
I'm thinking that this is related to limitations of windoze rather than
perl? Perhaps the dos bugaboo concerning the 64 meg memory limit???
Being pigheaded I tried to load more data several times, and eventually
noticed that my database was showing signs of corruption. Interesting.
The database still was very fast at returning values, just that the
values started to come up null in some fields and sometimes the whole
record would be shot.
Anyway, I wondered if anyone had experienced something similar? And if
these symptoms sound more like basic OS limitations, than perl
problems?
I've looked around a good deal trying to find some clues on this one,
but have had no luck. Could have missed what I'm looking for, if so a
pointer would be appreciated.
TIA,
Steve
------------------------------
Date: Wed, 11 Feb 1998 15:13:04 -0500
From: Edward Harris <Webmaster@eg-web.com>
Subject: Un crypt
Message-Id: <34E20650.EC2@eg-web.com>
If anyone has a good formula for uncrypting information previously
crypted using perls "crypt" command, I would appreciate knowing it.
Thank you much.
Ed Harris
------------------------------
Date: 11 Feb 1998 20:48:08 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Un crypt
Message-Id: <6bt2q8$b6@news-central.tiac.net>
In article <34E20650.EC2@eg-web.com>,
Edward Harris <Webmaster@eg-web.com> wrote:
>If anyone has a good formula for uncrypting information previously
>crypted using perls "crypt" command, I would appreciate knowing it.
If you can point a web browser at http://www.dejanews.com and search on
perl crypt decrypt
you might see the results of the last time a question like this came up.
If you have a recent perl installation then the crypt funxtion is
described in the perlfunc man page:
Encrypts a string exactly like the crypt(3) function in the C library
(assuming that you actually have a version there that has not been
extirpated as a potential munition). This can prove useful for checking
the password file for lousy passwords, amongst other things. Only the
guys wearing white hats should do this.
Note that crypt is intended to be a one-way function, much like breaking
eggs to make an omelette. There is no (known) corresponding decrypt
function. As a result, this function isn't all that useful for
cryptography. (For that, see your nearby CPAN mirror.)
Here's an example that makes sure that whoever runs this program knows
their own password:
$pwd = (getpwuid($<))[1];
$salt = substr($pwd, 0, 2);
system "stty -echo";
print "Password: ";
chop($word = <STDIN>);
print "\n";
system "stty echo";
if (crypt($word, $salt) ne $pwd) {
die "Sorry...\n";
} else {
print "ok\n";
}
Of course, typing in your own password to whoever asks you
for it is unwise.
Included in the copious on-line docs which come with perl these days there
are several pages of FAQs (frequently asked questions) and their answers.
perldoc perlfaq
should get the introductory page, if you don't have then then pointing a
web browser at http://www.perl.com will get you there
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 11 Feb 1998 20:58:14 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Un crypt
Message-Id: <6bt3d6$mvd$1@csnews.cs.colorado.edu>
Keywords: RTFM
[courtesy cc of this posting sent to cited author via email]
In a baleful but predictable revelation of his ignorance of the standard
online documentation that exist on his very own system, Edward Harris
<Webmaster@eg-web.com> writes: in comp.lang.perl.misc using the
abomination known as Mozilla 3.01 (Win95; I):
:If anyone has a good formula for uncrypting information previously
:crypted using perls "crypt" command, I would appreciate knowing it.
All perl distributions come with complete documentation. Checking
there would have been infinitely faster than posting.
$ man perlfunc
....
crypt PLAINTEXT,SALT
Encrypts a string exactly like the crypt(3) function in the C
library (assuming that you actually have a version there that
has not been extirpated as a potential munition). This can prove
useful for checking the password file for lousy passwords, amongst
other things. Only the guys wearing white hats should do this.
Note that crypt is intended to be a one-way function, much
like breaking eggs to make an omelette. There is no (known)
corresponding decrypt function. As a result, this function isn't
all that useful for cryptography. (For that, see your nearby
CPAN mirror.)
Prisoners of $Bill are still responsible for looking at manpages,
even if those should be available solely in lame HTML or raw POD.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Chip Salzenberg sent me a complete patch to add System V IPC (msg, sem and
shm calls), so I added them. If that bothers you, you can always undefine
them in config.sh. :-) --Larry Wall in <9384@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 11 Feb 1998 21:03:22 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Un crypt
Message-Id: <6bt3mq$ecq@fridge.shore.net>
Edward Harris (Webmaster@eg-web.com) wrote:
: If anyone has a good formula for uncrypting information previously
: crypted using perls "crypt" command, I would appreciate knowing it.
I have such a formula and will be unleashing it on every computer in
the world this evening. buahh-ha-haaaa!
Ahem.
Seriously, no there isn't. Even programs like crack don't decrypt a
password; they check it against a lexicon for matches.
--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov
------------------------------
Date: Wed, 11 Feb 1998 16:26:21 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
Subject: Re: Un crypt
Message-Id: <34E2177D.CDB72BFB@shopcfn.com>
Edward Harris wrote:
>
> If anyone has a good formula for uncrypting information previously
> crypted using perls "crypt" command, I would appreciate knowing it.
you cannot decrypt the results; you can only guess, encrypt your guess
with the same salt, and then compare to the first encrypted string for
equality. though it is a very easy formula, it is not generally quick.
--
dan boorstein <dboorstein@shopcfn.com>
------------------------------
Date: 11 Feb 1998 21:41:47 GMT
From: shaug@callamer.com (O'Shaughnessy Evans)
Subject: using undef (was Re: array question)
Message-Id: <6bt5ur$4i8$1@ha1.rdc1.occa.home.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> In comp.lang.perl.misc, shaug@callamer.com (O'Shaughnessy Evans) writes:
>: # All memory
>: # that was associated with it has effectively
>: # been released.
>
> That depends what you mean by released. It's still in your address space.
> You cannot hope to free memory in the negative sbrk sense of returning to
> the virtual memory system whence it came.
Hmm. As far as the program goes, though, the memory is available to
be processed by Perl's garbage collector, right? To elaborate...
If I was writing in C, and therefore had no garbage collector, I'd
use a loop that free()'d each element of array in this situation,
instead of calling undef(). Whether Perl or the OS's VM system know
how or care to make the most efficient use of the memory I've just
given away by calling undef() is no longer my concern... I've done
my part by doing the undef. Correct?
Thanks for taking the time to clarify this for me, Tom (and anyone else
who cares to pitch in) :-)
- shaug
--
O'Shaughnessy Evans
http://www.callamerica.net/shaug/
------------------------------
Date: Wed, 11 Feb 1998 14:49:09 -0600
From: Steve Dover <swd@strata-group.Xcom>
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <34E20EC5.B89A64A0@strata-group.Xcom>
John Stanley wrote:
>
> In article <34e1a394.337144498@news.iag.net>,
> Phil Barnett <dev.nul@iag.net> wrote:
> >On Wed, 11 Feb 1998 11:02:46 GMT, bart.mediamind@tornado.be (Bart
> >Lateur) wrote:
> >>Zooko Journeyman <zooko@xs4all.nl> wrote:
> >>>I glanced at the
> >>>Perl time functions, said "Holy shit! Looks like the Y2K
> >>>bug!", put "printf("19%2d", time);" for the timestamp, and made
> >>>a note to myself to check up on that bug.
> >
> >>You don't mention what it your error was. You've got me guessing.
> >In 2000, the code would have output 19100 instead of 2000. It's a bug.
> >
> in 2000, the code would output 1994 followed by 7 more digits.
>
> The only time the code would have output 19100 is on Jan 1, 1970, at
> 0:01:40 GMT.
>
> The code as presented would give a decodable and correct timestamp, as
> long as you ignore the "19" prepended to it. The only real question is
> why prepend the "19"?
Ok, you caught him. I think he meant to write
printf("19%2d", tm_year);
But your question is good, why prepend 19?
Because it's a common mistake with regard to tm_year.
The correct code would be
printf("%4d, tm_year + 1900);
As I said before,
'Y2k is not just for mainframes anymore'
------------------------------
Date: 11 Feb 1998 22:23:37 +0100
From: Zooko Journeyman <zooko@xs4all.nl>
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <6bt4sp$2g1$1@xs1.xs4all.nl>
Steve Dover <swd@strata-group.Xcom> wrote:
>John Stanley wrote:
>>
>> Phil Barnett <dev.nul@iag.net> wrote:
>> >On Wed, 11 Feb 1998 11:02:46 GMT, bart.mediamind@tornado.be (Bart
>> >Lateur) wrote:
>> >>Zooko Journeyman <zooko@xs4all.nl> wrote:
>> >>>I glanced at the
>> >>>Perl time functions, said "Holy shit! Looks like the Y2K
>> >>>bug!", put "printf("19%2d", time);" for the timestamp, and made
>> >>>a note to myself to check up on that bug.
>> >
>> >>You don't mention what it your error was. You've got me guessing.
>> >In 2000, the code would have output 19100 instead of 2000. It's a bug.
>> >
>> in 2000, the code would output 1994 followed by 7 more digits.
>>
>> The only time the code would have output 19100 is on Jan 1, 1970, at
>> 0:01:40 GMT.
>>
>> The code as presented would give a decodable and correct timestamp, as
>> long as you ignore the "19" prepended to it. The only real question is
>> why prepend the "19"?
>
>Ok, you caught him. I think he meant to write
>printf("19%2d", tm_year);
Yep-- sorry to post bad pseudocode.. (I was thinking of "time"
as a being a variable containing the value of tm_year, and
I neglected Perl variable syntax. Syntax isn't my strong
point...)
>But your question is good, why prepend 19?
>Because it's a common mistake with regard to tm_year.
>The correct code would be
>printf("%4d, tm_year + 1900);
Right.
This is probably a very common problem and should be in a FAQ
if it isn't already.
Regards,
Zooko
------------------------------
Date: Wed, 11 Feb 1998 14:59:19 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Yet Another Sorting Question(TM)
Message-Id: <34E20317.64FA@min.net>
David Fetter wrote:
>
> Right now, I have a crude, inextensible hack that doesn't
> quite work
> right--bombs when it runs across blanks in the key fields.
Wish I had time to debug this for ya ;-)
Just a couple remarks:
1. go ahead and use functions for elements like table, tr, td,
and a, since you're using others (provided CGI.pm).
2. Don't know why a space in a field would cause an error.
3. Make sure you have $, and $" set to appropriate values.
4. Does perl -w give you any warnings? What about use strict?
hth,
John Porter
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1862
**************************************