[11901] in Perl-Users-Digest
Perl-Users Digest, Issue: 5501 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 27 23:07:10 1999
Date: Tue, 27 Apr 99 20:00:20 -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 Tue, 27 Apr 1999 Volume: 8 Number: 5501
Today's topics:
Re: "learning perl" does not seem to be written well <bowman@montana.com>
Re: "learning perl" does not seem to be written well <cassell@mail.cor.epa.gov>
Re: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex( (Benjamin Franz)
Re: autoincrement magic a..z (James W. Sandoz)
complaints about debugger <ra5589@email.sps.mot.com>
Re: complaints about debugger <walton@frontiernet.net>
Re: count associate array (Tad McClellan)
Re: Country of a visitor (Abigail)
Re: E-Mail from NT Via Net::SMTP <metcher@spider.herston.uq.edu.au>
Re: FAQ 6.5: How do I substitute case insensitively on (Larry Rosler)
How to install DBI module toader@my-dejanews.com
Re: How to install DBI module (Paul Rahe)
Re: How to install DBI module <cassell@mail.cor.epa.gov>
Re: How to use FTP in perl?? <richb@ezl.com>
Re: Keeping order in a hash (Abigail)
Re: list of list <seugenio@man.amis.com>
Re: list of list <seugenio@man.amis.com>
Re: lwp-request hangs... <swarren@slip.net>
Re: Msg for Moderator/Flamers <juex@my-dejanews.com>
Perl and Y2K <gkaatz1@nycap.rr.com>
Re: Script Help (Larry Rosler)
Re: Script Help <cassell@mail.cor.epa.gov>
Re: Server Overload (Abigail)
strict vs. Win32::Registry <homelessinseattle@my-dejanews.com>
Re: stupid single quote " wipes out REST OF TEXT <cassell@mail.cor.epa.gov>
Re: stupid single quote " wipes out REST OF TEXT (Tad McClellan)
Re: syslog under Linux (RESOLVED!) (Tjerk Santegoeds)
Re: Where do the spaces come from (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 Apr 1999 18:31:37 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <pGsV2.227$Sx.1314@newsfeed.slurp.net>
David Cassell <cassell@mail.cor.epa.gov> wrote in message
news:3725E44B.A2C18DB6@mail.cor.epa.gov...
>
> Umm, creepy? Scary? Intimidating? Hastily written and too much like
> too many others you've seen? That's not a nice thing to say about C++.
I've said nastier....
> You may have seen too many *bad* Perl programs. Well-written Perl
> programs, like well-written C++ programs, are easy to read and follow.
> But looking at a few JAPHs before you learn about s/// and perlvars
> can make your cerebrum explode. I won't even mention the
> Schwartzian transform...
I think I saw too many one-liners. Many of the snippets in the zoo books are
readily apparent to the casual observer, as they say in physics. What
bothers me is the high density coding, with odd little default variables and
simple lines that transform into 'read and process every file in the glob'.
regex's can be little line noise puzzles in any language, including trying
to do something elegant from Vim's ex line.
Perl is certainly not as lexically dense as APL, but can be cerebrum
exploding. My fear is if I don't use it for n (days | weeks | months), I'll
incur a lot of the pain all over again. I'll fess up: for me, the more a
language looks like C, the better I like it. I'd probably love JavaScript if
you could actually do something useful with it.
------------------------------
Date: Tue, 27 Apr 1999 19:24:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <37267167.E811BAB@mail.cor.epa.gov>
bowman wrote:
>
> David Cassell <cassell@mail.cor.epa.gov> wrote in message
> news:3725E44B.A2C18DB6@mail.cor.epa.gov...
> >
> > Umm, creepy? Scary? Intimidating? Hastily written and too much like
> > too many others you've seen? That's not a nice thing to say about C++.
>
> I've said nastier....
Sounds like you'd be a welcome addition to this newsgroup. :-)
> > You may have seen too many *bad* Perl programs. Well-written Perl
> > programs, like well-written C++ programs, are easy to read and follow.
> > But looking at a few JAPHs before you learn about s/// and perlvars
> > can make your cerebrum explode. I won't even mention the
> > Schwartzian transform...
>
> I think I saw too many one-liners. Many of the snippets in the zoo books are
> readily apparent to the casual observer, as they say in physics. What
Ah yes. Just like in higher math, when the wizard says, "And this is
a trivial corollary..." Of course, in higher math, it's chalk only.
> bothers me is the high density coding, with odd little default variables and
> simple lines that transform into 'read and process every file in the glob'.
You mean like some of the mystical incantations that show up here
now and again? I find the `shortcuts' like <INFILE> and $! speed
things up for me. But the interface is not as consistent as Python.
That matters a lot for some people. I like the terseness when I just
want to whip out a fast file-mangler or dir-slicer or even sometimes
a math-torturer.
> regex's can be little line noise puzzles in any language, including trying
> to do something elegant from Vim's ex line.
Bigtime. One of the Good Things about Perl's regexen over most
everyone else's is the capacity to cope with that. The /x modifier,
the ability to switch to s### when you're transmuting pathnames,
or to s(something)(otherthing) when that's cleaner. Big helps in
improving readability. And Perl does a lot more to avoid
backslashitis than any other language or filter I know. And don't
get me started on Emacs backslash-escaping stuff.
> Perl is certainly not as lexically dense as APL, but can be cerebrum
What is? I've seen [and written] APL code that looked like someone
had uuencoded it already. No, that's not fair to uuencode.
> exploding. My fear is if I don't use it for n (days | weeks | months), I'll
> incur a lot of the pain all over again. I'll fess up: for me, the more a
When I first started tinkering with Perl, I wrote down a lot of the
cute idioms that I saw, and sort of used that as a cheat-sheet for
a bit. I wonder what happened to it...
> language looks like C, the better I like it. I'd probably love JavaScript if
> you could actually do something useful with it.
In the words of Randal Schwartz, 'heh'.
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Wed, 28 Apr 1999 02:50:47 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
Message-Id: <bIuV2.5506$oU1.519709@typhoon-sf.snfc21.pbi.net>
In article <7g4rrh$g9d$1@anathema.red.roses.de>,
Hans Maurer <hans@nosports.red.roses.de> wrote:
>Hija,
>
>Benjamin Franz wrote:
>> my ($tick) = @_;
>> my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst,
>> $month,$wkday);
>> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=gmtime($tick);
>[...]
>> if ($year < 95) {
>> $year = $year + 2000
>> }
>> if (($year > 94) && ($year < 1000)) {
>> $year = $year + 1900;
>> }
>
>I see year-mangling stuff like this all the time. As the perlfunc man page
[snip]
It is a legacy from code I wrote in the days of when the Pink Camel
was my primary reference and I was very new to Perl. The Pink Camel
didn't clearly indicate that what came back was year-1900
So I wrote code that would do the right thing pretty much no matter
*what* happened in 2000. If it rolled to 00 - it would add 2000
(classical Y2K). If it rolled to 100, it would add 1900. If it rolled
to 2000 (astoundingly there *are* languages which have this behavior
98, 99, 2000, ....) - it would leave it alone. So for all reasonable
cases in the next 100 years or so from when it was written - it would
do the right thing. It isn't terribly pretty - but it is very functional.
>So, a simple $year+=1900; does the trick. The code above will fail for
>time stamps earlier than 01/01/1995.
But I didn't need any dates before 1995. Or after 2999.
>Is there an issue on NT with gmtime that needs work-arounds like i
>the one above?
Not that I know of.
--
Benjamin Franz
------------------------------
Date: 27 Apr 1999 22:40:02 -0400
From: sandoz@umbc.edu (James W. Sandoz)
Subject: Re: autoincrement magic a..z
Message-Id: <7g5se2$9gjrf@umbc7.umbc.edu>
For what it's worth... Two code snippits posted which print a to z:
1. for ( $i = 'a' ; 1 ; $i++ ) {
last if $i eq 'z' ;
} }
2. for ($j="a"; $j le "z"; $j++) {
if( $j eq "aa") {last;}
else{
} } }
Benchmarked at 100000 iterations:
Code 1 report: code took 17 secs (17.68 usr 0.01 sys = 17.69 cpu)
Code 2 report: code took 33 secs (32.01 usr 0.02 sys = 32.03 cpu)
Looks like Uri's code wins.
--
Mr. James W. Sandoz, Instructor, UMBC Dept of Biol Sciences,
1000 Hilltop Circle
Catonsville, MD 21250
voice: (410) 455-3497; fax: 455-3875; net: sandoz@umbc.edu
------------------------------
Date: Tue, 27 Apr 1999 17:41:02 -0700
From: Peter Brooker <ra5589@email.sps.mot.com>
Subject: complaints about debugger
Message-Id: <37265914.1277FC07@email.sps.mot.com>
Consider the simple program below:
#!/usr/local/bin/perl -dw
$aa = join('',"00",$hash_table);
print "$aa";
Note that $hash_table is not defined. When I run the program I get
****** begin output ***********
Loading DB routines from perl5db.pl version 1.01
Emacs support available.
Enter h or `h h' for help.
Name "main::hash_table" used only once: possible typo at test.prl line 2.
Cannot print stack trace, load with -MCarp option to see stack at
/usr/local/lib/perl5/perl5db.pl line 1833.
main::(test.prl:2): $aa = join('',"00",$hash_table);
DB<1>
************ end output ***********
Nothing tells me that $hash_table is undefined.
If you really want to have some fun, try stepping through the program with the
"s" command.
After 100 lines, you finally get the warning
DB<1> s
Use of uninitialized value at test.prl line 2, <IN> chunk 1.
Use of uninitialized value at test.prl line 2, <IN> chunk 15.
main::(test.prl:3): print "$aa\n";
DB<1> s
00
DB::fake::(/usr/local/lib/perl5/perl5db.pl:2083):
2083: "Debugged program terminated. Use `q' to quit or `R' to restart.";
DB<1>
This finally gives you the clue that $hash_table is not defined.
Peter Brooker
------------------------------
Date: Tue, 27 Apr 1999 22:55:17 -0400
From: Bob Walton <walton@frontiernet.net>
To: Peter Brooker <ra5589@email.sps.mot.com>
Subject: Re: complaints about debugger
Message-Id: <37267895.BF2D656A@frontiernet.net>
Hmmm...I would say the "...used only once" is a pretty good hint that the variable
might be undefined. And besides, the use of an undefined variable in perl is not
a crime or even a bad thing -- the variable just returns the value "undef", which
can be tested for using the "defined" function. Adding the statement
print '$hash_table is undefined' unless defined($hash_table);
would detect the undefined status of variable $hash_table, for example. The
behavior of the debugger in this case seems to me to be perfectly aligned with
what perl is and does. C programmers might not expect this behavior of a
language, but it is fine with perl programmers -- perl isn't C.
Peter Brooker wrote:
> Consider the simple program below:
>
> #!/usr/local/bin/perl -dw
> $aa = join('',"00",$hash_table);
> print "$aa";
>
> Note that $hash_table is not defined. When I run the program I get
>
> ****** begin output ***********
> Loading DB routines from perl5db.pl version 1.01
> Emacs support available.
>
> Enter h or `h h' for help.
>
> Name "main::hash_table" used only once: possible typo at test.prl line 2.
>
> Cannot print stack trace, load with -MCarp option to see stack at
> /usr/local/lib/perl5/perl5db.pl line 1833.
> main::(test.prl:2): $aa = join('',"00",$hash_table);
> DB<1>
> ************ end output ***********
>
> Nothing tells me that $hash_table is undefined.
> If you really want to have some fun, try stepping through the program with the
> "s" command.
> After 100 lines, you finally get the warning
>
> DB<1> s
> Use of uninitialized value at test.prl line 2, <IN> chunk 1.
> Use of uninitialized value at test.prl line 2, <IN> chunk 15.
> main::(test.prl:3): print "$aa\n";
> DB<1> s
> 00
> DB::fake::(/usr/local/lib/perl5/perl5db.pl:2083):
> 2083: "Debugged program terminated. Use `q' to quit or `R' to restart.";
> DB<1>
>
> This finally gives you the clue that $hash_table is not defined.
>
> Peter Brooker
------------------------------
Date: Tue, 27 Apr 1999 15:52:15 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: count associate array
Message-Id: <fh45g7.k85.ln@magna.metronet.com>
bing-du@tamu.edu wrote:
: I know $#array+1 is the number of the elements of an array. Is there any
: ready-to-use operator or function to tell the element number of an associative
: array?
Perl FAQ, part 4:
"How can I know how many entries are in a hash?"
: Thanks in advance for your help.
Uh huh.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Apr 1999 00:41:12 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Country of a visitor
Message-Id: <7g5lf8$1tm$1@client2.news.psi.net>
Pierre-Luc (selectthree@gsig-net.qc.ca) wrote on MMLXV September MCMXCIII
in <URL:news:372620CE.22BB1D57@gsig-net.qc.ca>:
%% Yes you're missing something!:-)
%%
%% I don't want to ask; I want a counter to track it automatically.
You can't. You might be able to make a very rough estimate (heh, all
you can do with counters is make a very rough estimate of your number
of visitors anyway, let alone split that out to the countries they
visit from), but that will be based on some kind of reverse DNS lookup.
Which is quite a performance hit.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Wed, 28 Apr 1999 12:29:05 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: E-Mail from NT Via Net::SMTP
Message-Id: <37267271.46C8A54@spider.herston.uq.edu.au>
kstephan wrote:
>
> I installed Net::SMTP via "ppm install libnet", per Yong Huang, and when I
> execute the script found with ActivePERL, i.e,
Wow. You haven't checked a single return code. That takes guts, man.
Just in case you chicken out, here's a sample:
$smtp = Net::SMTP->new('smtp.xxx.com') || die "SMTP open bombed: $!";
> Could the answers that I gave when I installed Net::SMTP be part of the
> problem??
I don't think so. I didn't answer any questions for my installation,
and it works fine. But maybe the ppm thing is different.
>
> Thanks for any guidance!!
>
You're welcome.
--
Jaime Metcher
------------------------------
Date: Tue, 27 Apr 1999 18:51:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 6.5: How do I substitute case insensitively on the LHS, but preserving case on the RHS?
Message-Id: <MPG.11900970f98f748c989960@nntp.hpl.hp.com>
In article <MPG.118fbaa0d263d517989954@nntp.hpl.hp.com> on Tue, 27 Apr
1999 13:15:01 -0700, Larry Rosler <lr@hpl.hp.com> says...
...
> Well, fine. This is a nice C-ish program. But don't you think the FAQ
> should also (or, dare I say, instead) present a Perl solution? How many
> other examples in the FAQ show off Perl's magnificent bitwise ops
> working on strings?
Here is a benchmark (surprise!). The functions are as shown in the
previous posting. The control function just returns its first argument.
The data are the same, except that the string being processed is 10
repetitions of the string shown:
$a = "this is a TEsT case" x 10;
Benchmark: timing 4096 iterations of Cntrl, FAQ, LR...
Cntrl: 2 wallclock secs ( 2.58 usr + 0.00 sys = 2.58 CPU)
FAQ: 12 wallclock secs (12.47 usr + 0.00 sys = 12.47 CPU)
LR: 5 wallclock secs ( 4.88 usr + 0.00 sys = 4.88 CPU)
Neat, eh?
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 28 Apr 1999 01:20:15 GMT
From: toader@my-dejanews.com
Subject: How to install DBI module
Message-Id: <7g5noc$u0m$1@nnrp1.dejanews.com>
Hi!
I have ActivePerl on WindowsNT and want to install DBI 1.08 package on it.
Any help are welcome !
Andrew
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 28 Apr 1999 02:27:03 GMT
From: prahe@home.com (Paul Rahe)
Subject: Re: How to install DBI module
Message-Id: <37267205.202860467@news>
You can use PPM to install packages from ActiveState's web site,
including DBI.
Just open a command shell, migrate to the folder that contains Perl
and type PPM.
On Wed, 28 Apr 1999 01:20:15 GMT, toader@my-dejanews.com wrote:
>Hi!
>
>I have ActivePerl on WindowsNT and want to install DBI 1.08 package on it.
>Any help are welcome !
>
>Andrew
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 27 Apr 1999 19:46:50 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to install DBI module
Message-Id: <3726769A.49D43868@mail.cor.epa.gov>
toader@my-dejanews.com wrote:
>
> Hi!
>
> I have ActivePerl on WindowsNT and want to install DBI 1.08 package on it.
You *do* know about ppm, right?
(1) Make sure your network connection is up.
(2) Type at the command prompt:
ppm search DBI
I get this back:
Packages available from http://www.ActiveState.com/packages:
Apache-DBI
DBI
FindBin
Okay, so there's a DBI package just waiting for you there.
Now the hard part:
(3) Type this:
ppm install DBI
and wait while it does the install for you.
You might also want to check on the DBD packages available there.
> Any help are welcome !
Any help are provided.
I wonder if TomC's toolkit includes a grammar-checker.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Tue, 27 Apr 1999 20:26:02 -0500
From: Richard Brandt <richb@ezl.com>
Subject: Re: How to use FTP in perl??
Message-Id: <372663AA.37F4FAD1@ezl.com>
Steve,
I was faced with this issue in the past and after several attempts to
develop a solution on my own, I found the Perl module Net::FTP. This
will provide you with a seamless interface to the FTP protocol. It has
served me well. You can get it at any CPAN site, try www.perl.com and
follow the links to CPAN.
Good Luck,
Rich
steve wrote:
> Hi,
>
> I would like to know how to FTP a file in perl?
> What I need to do is that I need to use the FTP to transfer a file
> to a website.
>
> Thanks
>
> --Posted from EarthWeb Discussions. http://discussions.earthweb.com
------------------------------
Date: 28 Apr 1999 00:44:10 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Keeping order in a hash
Message-Id: <7g5lkq$1tm$2@client2.news.psi.net>
raanders@acc.jc.edu (raanders@acc.jc.edu) wrote on MMLXV September
MCMXCIII in <URL:news:7g58ea$g3d$1@nnrp1.dejanews.com>:
"" I am reading a file and creating a hash from the data read from that file.
"" The problem is that when the data is read in, instead of keeping the order
"" that the file is in, the hash is put in alphabetical order.
Well, don't keep it in a hash then! Note that a hash doesn't put it
in alphabetical order. It puts it in some order, which sometimes is
alpabetical, but often it's not.
If you want to keep the same order as you read it from file, use an array.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Wed, 28 Apr 1999 01:42:37 GMT
From: "Sheila Eugenio" <seugenio@man.amis.com>
Subject: Re: list of list
Message-Id: <01be9118$53f1a2e0$2bbe10ac@amipnet>
I hope you people can be less mean for beginners.........
> Yes, I have a script that's easier and better. But since you don't
> show any code, I won't show you any either.
>
>
> Abigail
> --
> srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split #
For Sun
> //=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n" #
Solaris
>
------------------------------
Date: Wed, 28 Apr 1999 01:45:11 GMT
From: "Sheila Eugenio" <seugenio@man.amis.com>
Subject: Re: list of list
Message-Id: <01be9118$b7bf1af0$2bbe10ac@amipnet>
Thank you, thank you very much! You have been a great help! Thanks!
------------------------------
Date: Wed, 28 Apr 1999 00:35:02 GMT
From: "Stephen Warren" <swarren@slip.net>
Subject: Re: lwp-request hangs...
Message-Id: <WIsV2.3765$gv5.2049@news.rdc1.sfba.home.com>
Ronny <ronald_f@my-dejanews.com> wrote in message
news:7g4180$bum$1@nnrp1.dejanews.com...
> Who can give me some hints of what goes wrong here?
>
> I have installed libwww and successfully did a 'gmake test'. Now I would
like
> to use lwp-request to fetch a file.
>
> This works fine for local files, i.e.
>
> but it does not fetch documents on the Web. When I try, for instance, to
get
> my homepage,
Sounds like you have a firewall/proxy server, which Netscape is configured
to use and libwww isn't?
------------------------------
Date: Tue, 27 Apr 1999 19:14:53 -0700
From: "J|rgen Exner" <juex@my-dejanews.com>
Subject: Re: Msg for Moderator/Flamers
Message-Id: <7g5qrt$sio@news.dns.microsoft.com>
<Webmaster@cybersystems2000.com> wrote in message
news:2Y1ZP30V.87772U4M@cybersystems2000.com...
> I am a small business owner just trying to make a buck. I have attempted
to filter out
> moderated news groups in an attempt to isolate only newsgroups that may
not mind my
> unobtrusive, and occasional advertisement for http://cybersystems2000.com
posted here.
> I sell a how to help style book. If I have been mis-informed and this is
in fact a
> moderated news group, or you frequent this site and are offended by my
request for
> visitors, PLEASE respond kindly to mailto:unsubscribe@cybersystems2000.com
> I will in turn immediately remove this news group from any further
postings.
Who the *&$^#% do you think you are?
If commercial postings are welcome or not has nothing to do with the NG
being moderated or not.
Each newsgroup has a charta and I estimate that at least 99% of them abolish
any commercial postings. If you decide to ignore those chartas, then expect
people to send complains to your ISP and sooner or later your account will
be cancelled. Most ISPs are very concered about the growing abuse of
internet accounts.
jue
--
J|rgen Exner
------------------------------
Date: Wed, 28 Apr 1999 02:11:58 GMT
From: "Glen Kaatz" <gkaatz1@nycap.rr.com>
Subject: Perl and Y2K
Message-Id: <01be911e$0843a590$ac255c18@glen>
OK,
Excuse the dumb management question, but is Perl 5.003 for NT Y2K
compliant?
Thanks,
An ashamed programmer
------------------------------
Date: Tue, 27 Apr 1999 17:36:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Script Help
Message-Id: <MPG.118ff7d7cc304bdd98995f@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7g5hti$jtb$1@bgtnsc03.worldnet.att.net> on Tue, 27 Apr 1999
23:40:25 GMT, JDDemme <jddemme@technologist.com> says...
> I'm working on a script o control what the user sees when the site lists the
> midis in a directory. each midi has a
> file called (filename of midi).txt. The first line of the midi is the name of
> the song, and the second line is the
> author. those are the only important lines here, for now. Here's the script.
> If speaks for itself. oh, and, top.txt is
> the html for the page up to the point where the data should be inserted.
Do you have a specific Perl question? I can see plenty of things to
improve (including fixing at least one typo that causes a syntax error
and makes me wonder whether this is the actual program cut-and-pasted,
or some resemblance of it).
Just a few general guidelines:
Use the '-w' flag to report warnings.
Use 'use strict;' to force you to declare all your variables.
ALWAYS check the results of open() or opendir() and print the results of
failure, including the value of $!.
Because this is a CGI program, you will have to decide how to deal with
warnings and fatal errors.
You *might* consider using CGI.pm (and others will tell you that you
*must* use it).
Some of your printing loops could be improved -- a lot!
...
<SNIP> of program
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 27 Apr 1999 19:36:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Script Help
Message-Id: <37267423.311C7428@mail.cor.epa.gov>
Larry Rosler wrote:
>
> You *might* consider using CGI.pm (and others will tell you that you
> *must* use it).
I wouldn't insist on it. But...
Until you are good enough at Perl that you can write working
versions of the pieces you need from CGI.pm, you should use it.
When I see This Larry or Benjamin Franz talk about using his own code
instead of CGI.pm, I know [from looking at their code in this
newsgroup] that they're capable of writing their own snippets to
do the parts of CGI.pm they want.
However, most CGI-HTML posters to this newsgroup who are writing
their own variants are usually doing a poor job of producing the
functions they need. This leads to broken programs, which
leads to desperate questions asked in newsgroups.
Use CGI.pm until you know enough to write something like it.
For most people, that means using it on a permanent basis.
But YMMV.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 28 Apr 1999 02:57:56 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Server Overload
Message-Id: <7g5tfk$27q$1@client2.news.psi.net>
JJ (webdude@mcminn.net) wrote on MMLXV September MCMXCIII in
<URL:news:B9qV2.3266$94.1358068@news1.usit.net>:
:: I recieved this message from my ISP and was wondering if any of you guru's
:: can help me figure out what the cause is.
::
:: This script was running about 15 copies on our web server machine
:: since around 7:00pm last night, causing excessive load. Please
:: take the script out of production or set some limits so this does not
:: happen.
::
:: Thanks,
:: It appears to me he is referring to the fact that the script is not
:: stopping after it is executed resulting in multiple instances of the script
:: being open and staying open. Anyone have any ideas?
Yes. Look carefully at line 17. Doesn't that ring a bell?
Abigail
--
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
------------------------------
Date: Wed, 28 Apr 1999 02:11:08 GMT
From: homeless <homelessinseattle@my-dejanews.com>
Subject: strict vs. Win32::Registry
Message-Id: <7g5qnq$i2$1@nnrp1.dejanews.com>
I'm trying to use:
use strict;
(in package main)
While at the same time using Win32::Registry (in a subroutine.)
The objects exported by Registry.pm,
namely $HKEY_LOCAL_MACHINE and such, disagree with strict in
my program.
Could someone please direct me to a faq on how to
declare objects from other modules in order to satisfy strict.
My search so far has been unsuccessful.
thanks in advance,
homeless
'To face death with mother is to
feel time move backwards. Twice.'
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 27 Apr 1999 19:04:50 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: stupid single quote " wipes out REST OF TEXT
Message-Id: <37266CC2.2095C4D5@mail.cor.epa.gov>
NOSPAMcrstlblu@planet.eon.net wrote:
>
> On Tue, 27 Apr 1999 10:13:46 -0700, David Cassell <cassell@mail.cor.epa.gov>
> wrote:
> >NOSPAMcrstlblu@planet.eon.net wrote:
> >> quotation mark in them (5'10") to be exact,... the 5'10" appears right smack in
> >> the middle of the text,....
> >
> >Tad already gave you the crucial information. But I noticed this:
> >> strange, I've tried various things with the (=~tr/"//;), (=~tr/\"//;) and so on
> >> to no avail,... any suggestions?
> >
> >You need to look up tr/// in the perlop manpage. Use `man' or
> >`perldoc' or the html docs, or whatever you like.
> >If you want to get rid of them, you need to do this:
> >
> > $varname =~ tr/"//d;
> >David
>
> thanks Dave, I tried it, and it didn't work either???
> the text string is about 400 characters long, it was passed into the next SCRIPT
> by the post method, was parsed, and the single quote is right smack in the
> middle of the VALUE OF it :)
>
> I still lose BOTH the single quote, as well as the 200 characters AFTER
> the single quote :)
Well, if it's a *single* quote instead of a double quote, thne you would
change my line to:
$varname =~ tr/'//d;
Or, to handle both cases,
$varname =~ tr/"'//d;
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Tue, 27 Apr 1999 17:35:59 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: stupid single quote " wipes out REST OF TEXT
Message-Id: <vja5g7.8d5.ln@magna.metronet.com>
[
NOSPAMcrstlblu@planet.eon.net wrote:
: On Tue, 27 Apr 1999 10:13:46 -0700, David Cassell <cassell@mail.cor.epa.gov>
: wrote:
: >NOSPAMcrstlblu@planet.eon.net wrote:
: >> I've got this mysterious problem with a crummy " quotation mark,
: >> in my flatfile dbm database, I have several lines of text which have a crummy
: >> quotation mark in them (5'10") to be exact,... the 5'10" appears right smack in
: >> the middle of the text,....
: >
: >Tad already gave you the crucial information. But I noticed this:
: >
: >> strange, I've tried various things with the (=~tr/"//;), (=~tr/\"//;) and so on
: >> to no avail,... any suggestions?
: thanks Dave, I'll try it, but i still don't see why everyone thinks this
: is a HTML problem????
Because that is what it is!
Really!
You are not generating correct HTML.
Correct HTML requires that double quote chars in attributes
be escaped.
Are you escaping the double quote characters the way that
the HTML spec says to escape double quote characters yet?
(It was suggested that you do this several followups ago.
If you are going to ignore the advice you get here, then
why bother even asking?
)
If you go find out how to do this, and then do it, your problem
will go away.
Stop posting to the Perl newsgroup with this problem!
It is an HTML problem.
Have you even tried asking in the HTML newsgroup yet?
That is the solution to your problem.
The solution to your problem is to be found in the
specifications for HTML, which has nothing to do with
Perl, and is therefore off-topic here in the Perl newsgroup.
The solution to your problem is to generate valid HTML.
You are not generating valid HTML.
Stop posting to the Perl newsgroup with this problem!
I am a hair's breadth from feeling compelled to *plonk*
you for insisting on continuing with your off-topic thread...
: the first CGI GENERATED script opens a DBM file, and a variable gets
: declared something like:
: $thetext = $dbhash{$fields{'thedbkey'}};
: $thetext now contains a textstring of... I am 5'10" tall
: and prints to the browser on a cgi gen'd page PERFECTLY!
: if THIS SCRIPT also printed a NEW FORM under that with a hidden field like
: <input type=\"hidden\" name=\"whatever\" value=\"$thetext\">
So look at the output from the part of a print statement above.
That is the generated HTML that I suggested you look at before.
Have you looked at it yet?
What does it look like?
I'll bet it looks like this:
<input type="hidden" name="whatever" value="I am 5'10" tall">
^^^^^^^^^^^
^^^^^^^^^^^
Which is not legal HTML.
And that is the *end of the value attribute's value*
"tall" is then taken to be yet another attribute in your
<input> element.
You want instead:
<input type="hidden" name="whatever" value="I am 5'10" tall">
Which is legal HTML.
: once SUBMITTED, the NEXT script parses, and prints to the browser
: print "the value of the text field is $fields{'whatever'}\n";
: both the SINGLE QUOTE, as well as EVERYTHING AFTER IT gets lost.
It is a "double quote", not a 'single quote'.
: I don't understand how this is a html problem, sounds more like a parseing
: problem to me???? but hey, I've only been at this 4 months :)
Several people who have been at this for a whole lot longer
than that have said that it is an HTML problem.
Do you think that you are right and everybody else is wrong?
: remove "SPAM" from email to reply :)
remove "SPAM" from email to get replies.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 27 Apr 1999 22:20:32 GMT
From: tjerk@dias.iaehv.nl (Tjerk Santegoeds)
Subject: Re: syslog under Linux (RESOLVED!)
Message-Id: <slrn7ice1g.2v0.tjerk@dias.iaehv.nl>
On Mon, 26 Apr 1999 03:53:05 GMT, Neil Cherry <njc@dmc.uucp> wrote:
>Several of us (Linux users) have noticed that using syslog has failed
>with the Red Hat release. I've upgraded to Perl 5.00502 and I think I
>may have a solution:
>
> use Sys::Syslog qw(:DEFAULT setlogsock);
>
> $program = "Foo";
>
> setlogsock('unix'); # This is the difference ???
> openlog("$program $$", 'ndelay', 'user');
> syslog('notice', 'fooprogram: this is really done');
>
>The following code fragment works on my Linux box where I've upgraded
>but fails on the older (rpm installed) version. I hope this helps.
I'm aware of the fact that upgrading to a newer version of Perl is a
better solution, but the following could be used as a temporary
workaround (RedHat 5.2).
Edit '/usr/lib/perl5/Sys/Syslog.pm' and change:
@EXPORT = qw(openlog closelog setlogmask syslog);
to
@EXPORT = qw(openlog closelog setlogmask syslog setlogsock);
Then in your program:
use Sys::Syslog;
setlogsock('unix');
openlog('program', 'pid', 'user');
syslog('debug', 'This works');
Regards,
Tjerk.
--
Tjerk Santegoeds
Basingstoke - UK
------------------------------
Date: Tue, 27 Apr 1999 15:47:22 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Where do the spaces come from
Message-Id: <a845g7.k85.ln@magna.metronet.com>
sstarre@my-dejanews.com wrote:
: As I said, I also tried
: print @l;
But *that* isn't interpolating an array either!
print "@l";
*that* is interpolating an array.
: Same result John, don't let this response confuse you- I did try your example
: as well as the other.
Try it like the above (which is also how John did it).
If you do not get the extra spaces, then there is something
wrong with your perl.
: In article <v114g7.7l4.ln@magna.metronet.com>,
: tadmc@metronet.com (Tad McClellan) wrote:
: > [ quotes moved around into non-Jeopardy order ]
: >
: > sstarre@my-dejanews.com wrote:
: > : In article <P1gV2.3449$B55.276363@dfiatx1-snr1>,
: > : "John T. Drefke" <jtdrefke@gte.net> wrote:
: > : > print "@x";
: >
: > : Perhaps it is something with your implementation, as I tried your example on
: > : our unix system and I don't see any spaces:
: >
: > But you didn't try his example.
: >
: > His example interpolates an array into a string.
: >
: > Your example doesn't.
: >
: > : foreach (@l) {print;}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5501
**************************************