[13621] in Perl-Users-Digest
Perl-Users Digest, Issue: 1031 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 10 12:05:43 1999
Date: Sun, 10 Oct 1999 09:05:21 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <939571520-v9-i1031@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 10 Oct 1999 Volume: 9 Number: 1031
Today's topics:
add value of hidden field in the search query <theages@yahoo.com>
Re: Bug with localtime() in Perl 5.004 and 5.005 (M.J.T. Guy)
Re: Checking for processes (M.J.T. Guy)
Deciphering Error Messages: A Lesson <jeffp@crusoe.net>
External site search ( possible?? ) (Bobo)
Re: Help - Perl regular expression question! <ltl@rgsun40.viasystems.com>
Re: help! (one more time)... <dave@dave.org.uk>
Re: help! (one more time)... (Tad McClellan)
Re: howto load modules to an ISP website? <dtbaker_@busprod.com>
Re: howto load modules to an ISP website? <dtbaker_@busprod.com>
Re: Is $$variable allowed like in PHP ? (Tad McClellan)
Just Two LWP::UserAgent questions (Bill Moseley)
Re: Looking for a perl version?? (M.J.T. Guy)
Re: need csh > perl advice <flavell@mail.cern.ch>
Re: need csh > perl advice (Tad McClellan)
Re: need csh > perl advice (Tad McClellan)
Perl - login to http site merksperks@hotmail.com
Perl CGI/Browser Output Bug - Help! <carlo.mantini@fmr.com>
Re: perl compiler for Win32? <dtbaker_@busprod.com>
Question? Writing to file <ICEMOUNTAIN@prodigy.net>
Re: search a file on a remote server <homelessinseattle@yahoo.com>
Re: Shell and Perl have different $? <ltl@rgsun40.viasystems.com>
Re: tool to convert BMPs to GIFs programatically? (J. A. Mc.)
Re: tool to convert BMPs to GIFs programatically? (J. A. Mc.)
Re: Trouble understanding HTML Parsing <skilchen@swissonline.ch>
Re: Trouble understanding HTML Parsing (brian d foy)
Re: Trouble understanding HTML Parsing <jtolley@bellatlantic.net>
Unique ID <joe@somewhere.net>
URLs and what they mean, was Re: Help! <flavell@mail.cern.ch>
while (<MAYA>) read 1 line of 2 ? <vampiloup@crosswinds.net>
Re: while (<MAYA>) read 1 line of 2 ? <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 10 Oct 1999 17:29:29 +0200
From: "Sven Schoppen" <theages@yahoo.com>
Subject: add value of hidden field in the search query
Message-Id: <7tqbct$nk9$1@fu-berlin.de>
hi!
i want to modifiy a cgi-script that i use as a small search engine.
http://technotrade.com/cgi/search.html
to search in sub categories i want to define a hidden field in the
search-mask. the value of the hidden field should be submitted
in the search string.
for that i have to modifiy the cgi skript to read the value of the
hidden field together with the words the people tipe in the search
mask.
here is the part of the script where i think i have to make the
modifications. please check als the original skript:
http://technotrade.com/cgi/search.html
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}
i know there are better ways to write the read routine (with CGI.pm)
but i am simple not able to make this modifications.
i just want to use the routine and want to modify the skript so that it
reads the value of the hidden field and the words in the search mask.
do you have suggestions?
thank you in advance
a perl newbie
regards
sven
------------------------------
Date: 9 Oct 1999 16:05:03 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Bug with localtime() in Perl 5.004 and 5.005
Message-Id: <7tnp3f$do6$1@pegasus.csx.cam.ac.uk>
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>
>Moreover, leap seconds are "mostly" governed by the changes in the
>rate of Earth rotation, which IIRC are in turn mostly governed by
>whether changes. Since one cannot predict the latter, making
>prediction about the former would be kinda stupid.
Nope. Leap seconds are governed by administrative decision of the
IERS. Of course, they base their decisions on their knowledge
of the relevant physics.
Their decisions are issued at "Bulletin C", issued in mid-January and
mid-July, and specifying whether the following June/December will
have a leap second. So you can predict leap seconds at least
5.5 months ahead.
>One can observe the known (scarce) statistical data and make some
>reasonable "if nothing changes" probabilistic predictions, nothing
>more.
That's of course what the IERS do. And their predictions of UT1-TAI
are routinely accurate to a few milliseconds, plenty more accurate
that required for deciding leap seconds.
Mike Guy
------------------------------
Date: 9 Oct 1999 16:55:42 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Checking for processes
Message-Id: <7tns2e$g6q$1@pegasus.csx.cam.ac.uk>
In article <7tlmdk$6fp$1@nnrp1.deja.com>, <schan6128@my-deja.com> wrote:
>
>
>>
>> kill 0, $pid should do this, as documented in perlipc. If not,
>> your Perl is broken.
>>
>> What platform are you on, and what version of Perl?
>
>I am running perl on Windows NT. It is the active perl 5.19. Could it
>be NT screwing things up?
Sounds likely. Your first message talked about using 'ps'.
So I assumed you must be on some sort of Unix.
Don't use Windows myself, but I found this in
README.win32 in the Perl source (along with lots of similar items):
C<kill()> is implemented, but doesn't have the semantics of
C<raise()>, i.e. it doesn't send a signal to the identified process
like it does on Unix platforms. Instead it immediately calls
C<TerminateProcess(process,signal)>. Thus the signal argument is
used to set the exit-status of the terminated process. This behavior
may change in future.
Mike Guy
------------------------------
Date: Sat, 9 Oct 1999 13:00:49 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Deciphering Error Messages: A Lesson
Message-Id: <Pine.GSO.4.10.9910091234480.14462-100000@crusoe.crusoe.net>
I was on #perl this morning, and someone had come up with a very
interesting error message, one that I had never run into before. That
wasn't the only reason it was interesting, of course; the wording
describing an event I didn't think seemed reasonable:
Can't use subscript on not at error.pl line 9, near ""No Line\n" }"
Execution of error.pl aborted due to compilation errors.
Now, as convention dictates, the #perl fellow showed the horrific "line 9"
which stated something like this:
if (!$line) { die "No Line\n" }
I thought, "That's a bizarre error message to get. The program must have
an unmatched bracket or brace or parenthesis that Perl is resolving on
that line." So I asked for the previous line. I got the previous TWO
lines:
alarm 0;
}
The guy said he was quite sure he had no mismatched symbols. At that
point, I asked if the two lines of code he just showed me were from an
eval block. If they were, I knew how to fix the problem, and perhaps more
importantly, why Perl returned the error it did, instead of something that
would be more helpful, such as a "runaway from line XX (possibly due to a
missing ;?)" error.
It was an eval block. I had figured as much -- the alarm() function
tipped me off.
The solution was to place a semicolon after that closing brace of the eval
block. "I've never seen a semicolon after a } before" he said, a little
puzzled, but happy that it fixed the problem. The reason is because
semicolons can be omitted after control structure blocks in the following
format:
if (COND) {
...
}
The same goes for elsif, else, while, until, unless, for, foreach, and I
think that's all there are. Trust Perl 5.6 to sneak up on me and add
another under my nose, making this document obsolete. :) The semicolon
can also be omitted after NAMED subroutine declarations:
sub foobar {
...
}
sub foo ($$) {
..
}
sub bar ();
I say "NAMED" because when the sub { ... } construct is used to return a
code reference, there needs to be a semicolon following the sub { .. }
block. (Of course, the semicolon is a SEPARATOR in Perl, unlike a
TERMINATOR in C and C++, so there are areas where ending semicolons can be
omitted, but I tend to have them all in there.)
"So what was with that error message?"
Luckily (you might say "?") this error message, when given some logic,
makes a great deal of sense. His code construct was basically as follows:
dosomething # with no ending semicolon!
if (!condition) { thendothis; }
Perl saw it like this:
dosomething if (!condition) { thendothis; }
Note, too, that THIS line has no ending semicolon. So if your next line
was something like C<print "Match: $line\n";>, you'd get a
syntax error at error.pl line 10, near "print"
error as well. Now, to Perl, this is good enough:
dosomething if condition;
# or
dosomething if !condition;
However, the specific construction was this:
dosomething if (!$line) { ... }
which Perl thought to be:
dosomething if ( (!$line){HASH_SUBSCRIPT} )
Strip away to the problem point, and you have:
(!$line){HASH_SUBSCRIPT}
And as Perl told us, you can't take a subscript on a 'not'.
The moral of the story? Well, I'm a rotten little bugger, and I don't use
the builtin perl debugger too often. I try to think it out and use brute
force and logic the human way, before I let Perl help me. I'm not saying
this is healthy, or that I always win. I don't know what I was going to
say. I guess, just that Perl's errors aren't always as cryptic as they
sound, if you apply some logic.
Thus endeth the lesson.
--
jeff pinyan japhy@pobox.com
perl stuff japhy+perl@pobox.com
CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN
------------------------------
Date: 9 Oct 1999 16:01:01 GMT
From: bobo@bobo.com (Bobo)
Subject: External site search ( possible?? )
Message-Id: <7tnort$4jd6@imsp212.netvigator.com>
Any CGI script that can perform external site search ?? (I mean free download)
i.e., A CGI hosted site (search engine) can search all files in another
non-CGI hosted site.
Thanks if you can help.
------------------------------
Date: 9 Oct 1999 16:23:50 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Help - Perl regular expression question!
Message-Id: <7tnq6m$kdm$1@rguxd.viasystems.com>
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
:>[A complimentary Cc of this posting was sent to lt lindley
:><lee.lindley@bigfoot.com>],
:>who wrote in article <7tma6q$6kt$1@rguxd.viasystems.com>:
:>> Arrgggg. An answer that works but doesn't use the best regexp engine
:>> tools that are available. Your answer is admiribal. I hope the
:>> question is adequatly answered.
I just wish I wouldn't post when I'm too sleepy to spell correctly.
:>I always ask myself whether (very much optimized)
:> /foo(?<!kfoo(?=d))/; # Match foo not inside kfood
:>can be written more readable and less error-prone.
As for that regexp, a positive lookahead inside a negative lookbehind,
I don't care how optimized it is. It looks like time travel to me
and so may never be "readable and less error-prone" to us simple
non-time traveling creatures.
I think I finally parsed it. Why is it any better than
/foo(?<!kfoo)(?=d)/
# or
/(?<!k)foo(?=d)/ # Much easier to read IMO
------------------------------
Date: Sun, 10 Oct 1999 15:50:36 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: help! (one more time)...
Message-Id: <uKcAODgSz0k+BToAgtRvu0kEKXjt@4ax.com>
On Sun, 10 Oct 1999 13:54:36 +0100, "Acacia" <acacia@online.no> wrote:
>ok, i think i made myself a bit unclear last time....
>
>the following code is for sorting and printing the top10 visited locations
>(subdirectories within home.domain.com in this case...).
>however, i'm not interested in the entire URL. I just want the last
>directory
>to be displayed. At the end of the code...
>
>Content of 'npcount.db'
>
>2|http://home.domain.com/meredith/|
>1|http://home.domain.com/eddy/|
>4|http://home.domain.com/lucas/|
>1|http://home.domain.com/mista/|
>
># END
>
>Content of 'top10.pl'
>
>#!/usr/bin/perl
>$data = '/usr9/home/acacia/public_html/home/cgi-bin/npcount.db';
>
>open(DATA,"$data") || die "Open DATA Failed: $!\n";
>@data = <DATA>;
>close(DATA);
>
> foreach $line (@data) {
> chomp($line);
>
> ($number,$download) = split(/\|/,$line);
>
> $data[$x] = "$number||$download";
>
> $x++;
> }
>
> @data = sort { $b <=> $a } @data;
>
>print "Content-type: text/html\n\n";
>
> for ($i=0; $i<10; $i++) {
> $link = $data[$i];
>
> if ($link ne "") {
> ($number,$download) = split(/\|\|/,$link);
>
> print "- <a href=\"$download\">$download</a><br>\n";
> }
> }
>
># END
>
>
>This code results in the output...
>
>- http://home.domain.com/lucas/
>- http://home.domain.com/meredith/
>- http://home.domain.com/eddy/
>- http://home.domain.com/mista/
>
>
>What I would like would look something like...
>
>- /lucas/
>- /meredith/
>- /eddy/
>- /mista/
I think you want something a bit like this:
use strict;
my @data;
while (<DATA>) {
chomp;
my %rec;
($rec{count}, $rec{dir}) = split(/\|/, $_);
$rec{out} = $rec{dir};
$rec{out} =~ s|^.*(/[^/]+/)$|$1|;
push @data, {%rec};
}
my @data = sort { $b->{count} <=> $a->{count} } @data;
print "Content-type: text/html\n\n";
for (0 .. 9) {
print "- <a href='$data[$_]->{dir}'>$data[$_]->{out}</a><br>\n";
}
__END__;
2|http://home.domain.com/meredith/|
1|http://home.domain.com/eddy/|
4|http://home.domain.com/lucas/|
1|http://home.domain.com/mista/|
3|http://home.domain.com/someone/|
8|http://home.domain.com/other/|
9|http://home.domain.com/made_up/|
10|http://home.domain.com/invented/|
15|http://home.domain.com/who/|
0|http://home.domain.com/me/|
2|http://home.domain.com/yes_you/|
6|http://home.domain.com/ok/|
hth,
Dave...
--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>
------------------------------
Date: Sun, 10 Oct 1999 06:06:30 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help! (one more time)...
Message-Id: <6fopt7.kcq.ln@magna.metronet.com>
Acacia (acacia@online.no) wrote:
: ok, i think i made myself a bit unclear last time....
^^^^^^^^^
What "last time"?
This post does not have a References: header, which it should
have if it is indeed making reference to some previous post.
You should not circumvent the normal operation of Usenet like that...
: the following code is for sorting and printing the top10 visited locations
: (subdirectories within home.domain.com in this case...).
: however, i'm not interested in the entire URL. I just want the last
: directory
: to be displayed. At the end of the code...
: #!/usr/bin/perl
You are missing the -w switch there.
#!/usr/bin/perl -w
You are missing a use strict pragma there also:
use strict;
[ snip code ]
: print "- <a href=\"$download\">$download</a><br>\n";
: This code results in the output...
: - http://home.domain.com/lucas/
: - http://home.domain.com/meredith/
: - http://home.domain.com/eddy/
: - http://home.domain.com/mista/
No it doesn't.
It results in this output:
- <a href="http://home.domain.com/lucas/">http://home.domain.com/lucas/</a><br>
- <a href="http://home.domain.com/meredith/">http://home.domain.com/meredith/</a><br>
- <a href="http://home.domain.com/eddy/">http://home.domain.com/eddy/</a><br>
- <a href="http://home.domain.com/mista/">http://home.domain.com/mista/</a><br>
: What I would like would look something like...
: - /lucas/
: - /meredith/
: - /eddy/
: - /mista/
---------------------------
#!/usr/bin/perl -w
use strict;
# sort it as it is read in. We don't need no stinkin' temp array
# (this is gonna be really slow for large files, but the standard
# perl docs already show how to make it faster)
# grep() removes "blank lines"
my @data = sort { (split /\|/, $b)[0] <=> (split /\|/, $a)[0] }
grep /./, <DATA>;
foreach (@data) {
my $download = (split /\|/, $_)[1]; # grab the second field
$download =~ s#.*(/.*/)$#$1#; # leave stuff between the last 2 slashes
# alternate quoting to avoid a bunch of backslashing
print qq(- <a href="$download">$download</a><br>\n);
}
__DATA__
2|http://home.domain.com/meredith/|
1|http://home.domain.com/eddy/|
4|http://home.domain.com/lucas/|
1|http://home.domain.com/mista/|
---------------------------
output:
- <a href="/lucas/">/lucas/</a><br>
- <a href="/meredith/">/meredith/</a><br>
- <a href="/eddy/">/eddy/</a><br>
- <a href="/mista/">/mista/</a><br>
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 10 Oct 1999 10:53:44 -0500
From: Dan Baker <dtbaker_@busprod.com>
Subject: Re: howto load modules to an ISP website?
Message-Id: <3800B688.7074AA69@busprod.com>
Abigail wrote:
>
> Dan Baker (dtbaker@busprod.com) wrote on MMCCXXX September MCMXCIII in
> <URL:news:37FFC3CF.CCC0E430@busprod.com>:
> .. I have a website that needs to use the optional module Image/Size.pm and
> .. my ISP is reluctant to load it for some reason. I have been attempting
> .. to copy required files and create a "site" for optional modules in my
> .. cgi-bin dir, but I must be missing copying or editting some pieces for
> .. the auto-loader or something because I cant get things to work
> .. correctly.
>
> That's a FAQ, isn't it?
>
> Abigail
--------------------
gee Abigail... if you KNOW its a fact, how about a little hint on where
to find it rather than just make a comment that has no positive helpful
content?! What FAQ, and what topic maybe?
Dan
------------------------------
Date: Sun, 10 Oct 1999 11:00:38 -0500
From: Dan Baker <dtbaker_@busprod.com>
Subject: Re: howto load modules to an ISP website?
Message-Id: <3800B826.4F1A3FCD@busprod.com>
good ideas, but the Image/Size.pm module seems to do some tricky stuff
with autoloader, and requires other pieces. I already created a user
"site" at /user/cgi-bin/site/Image/... and explicitly unshifted @INC to
add the path. I will try your "use lib" method. I get strange errors
from autoloader and that I might not have stripped carriage returns.
Doesnt make a lot of sense since I uploaded the .pm as text?
Maybe this particular module has some strange stuff in it? Has anyone
been able to upload and use it in a user cgi-bin dir?
thanx,
Dan
------- original message follows:
David Efflandt wrote:
>
> On Sat, 09 Oct 1999 17:38:07 -0500, Dan Baker <dtbaker@busprod.com> wrote:
> >I have a website that needs to use the optional module Image/Size.pm and
> >my ISP is reluctant to load it for some reason. I have been attempting
> >to copy required files and create a "site" for optional modules in my
> >cgi-bin dir, but I must be missing copying or editting some pieces for
> >the auto-loader or something because I cant get things to work
> >correctly.
> >
> >Is there a reasonably easy way to upload a module like this (things that
> >are normally installed to /usr/bin/site ) to a user cgi-bin site and
> >configure it?
>
> I am not familar with that particular module or whether it involves any
> binaries, but it is simple if the module is just Perl code. For example
> to install MIME::Lite I simply created my own 'site_perl' dir. Made a
> MIME dir there and put Lite.pm in that. Then a 'use lib' statement will
> unshift your path to the @INC search paths:
>
> use lib '/full_path_to_my/site_perl';
> use MIME::Lite; # searches for MIME/Lite.pm in my site_perl
>
> I did similarly for Mail::Sendmail on a free site that has Unix sendmail
> disabled due to spammers and it works fine.
>
> >--
> >Thanx, Dan
> >
> ># If you would like to reply-to directly, remove the - from my username
> >* no spam please... regulated by US Code Title 47, Sec.227(a)(2)(B) *
>
> --
> David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
> http://www.de-srv.com http://cgi-help.virtualave.net/
> http://thunder.prohosting.com/~cv-elgin/
--
Thanx, Dan
# If you would like to reply-to directly, remove the - from my username
* no spam please... regulated by US Code Title 47, Sec.227(a)(2)(B) *
------------------------------
Date: Sun, 10 Oct 1999 04:47:48 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Is $$variable allowed like in PHP ?
Message-Id: <krjpt7.11q.ln@magna.metronet.com>
Jonathan Stowe (gellyfish@gellyfish.com) wrote:
: On Fri, 08 Oct 1999 11:59:20 -0700 David Cassell wrote:
: > <The Brain>
: > Are you pondering what I'm pondering?
: > </The Brain>
: >
: > Can PHP be the cause of all these "I want to do $$name = value"
: > questions that show up here?
: No I think its the inability of people to analyse the problem they are trying
: to solve sufficiently. I dont believe I have ever heard anyone who has
: trained as a programmer ask this question.
: I think the question is why people want to do it in Perl and not in C,
: COBOL or BCPL ?
The answer to that one is simple.
Because those languages have such a high barrier to entry,
that there are very few folks who can get anywhere with
them unless they have trained as a programmer.
It is like the first two weeks of High School football practice.
They are waaaaay harder than "normal" practices prove to be.
It is done to weed out the guys that lack commitment.
Perl does not require a high level of commitment to use.
It is so easy to use, that non-trained folks can use it,
and rediscover all of the classic problems (goto, global
vars...) that were solved in the '60s and '70s :-(
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 10 Oct 1999 08:20:09 -0700
From: moseley@best.com (Bill Moseley)
Subject: Just Two LWP::UserAgent questions
Message-Id: <MPG.126a4e7747ae823d9897ee@nntp1.ba.best.com>
I'm using the form of $ua->request() where you pass a ref to a sub and a
chunk size.
Question 1: Is it possible to make the chunk size so small that
LWP::UserAgent won't get all the headers, or will it get the headers no
matter what? All I want are the headers, but I need to use the GET
method.
Question 2: Net::FTP spits out this warning:
Net::FTP: Bad hostname 'badhostname' at....
When accessed as below. Anyway to make the request without warnings,
short of turning $^W off?
#! perl -w
use strict;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
my $req = HTTP::Request->new( 'GET' => 'ftp://badhostname/' );
my $res = $ua->simple_request($req);
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: 9 Oct 1999 16:12:38 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Looking for a perl version??
Message-Id: <7tnphm$e5k$1@pegasus.csx.cam.ac.uk>
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>On Thu, 07 Oct 1999 14:23:06 +0200,
> Alexandre Amelin <aamelin@mmm.com> wrote:
>> I'm looking for a hold version of perl for Windows :
>> Version 4.0.1.8 Build 3 Patch level 36.
>
>I am not joking. The version you are talking about is _ancient_. There
>were even newer releases of perl 4 after that one.
Actually, no. According to 'perldoc perlhist', the last version of
perl4 was 4.036 (i.e. Patch level 36).
But that doesn't detract from the rest of your remarks.
Mike Guy
------------------------------
Date: Sun, 10 Oct 1999 15:53:28 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: need csh > perl advice
Message-Id: <Pine.HPP.3.95a.991010155142.7619A-100000@hpplus01.cern.ch>
On Sun, 10 Oct 1999, Matt Hadder stood usenet on its head with:
> Heh heh... I may be an enigma... I use comments extensively.
I've seen defective programs that would have worked great if the
comments had been executed instead of the code.
Mind you, deep in the IBM VM operating system source we once found a
comment that said "remember to collect laundry on way home".
------------------------------
Date: Sun, 10 Oct 1999 04:56:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: need csh > perl advice
Message-Id: <3bkpt7.11q.ln@magna.metronet.com>
Matt Hadder (reply@the.ng) wrote:
: I am a decent csh programmer.
Ack!
"Csh Programming Considered Harmful"
http://www.perl.com/pub/language/versus/csh.html
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 10 Oct 1999 05:04:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: need csh > perl advice
Message-Id: <9rkpt7.11q.ln@magna.metronet.com>
Matt Hadder (reply@the.ng) wrote:
: I was looking for advice. I just changed jobs recently. At my old job I
: wrote mainly in Unix C Shell. I am a decent csh programmer. My new
: position is in a group developing in Perl. The function of the programs I
: will be writing will be the same or very similar to what I have done in the
: past. Also, I have inherited the task of porting a set of automation
: scripts from csh to Perl.
: My questions:
: Is there some good documentation for avoiding pitfalls when coming from
: another language to Perl?
perldoc perltrap
Especially the "Shell Traps" section.
[ The first thing you should realize about Perl is that it
*comes with* good documentation ( >1000 pages) for most
everything.
'perldoc' is a program that also comes with perl. It looks
things up in the standard documentation for you.
So the above is the Perlish way to say:
"You should read the perltrap.pod standard Perl doc"
]
: Does anyone have advice as to the approach to take or things to avoid when
: porting from csh to Purl?
perldoc perltrap # again :-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 10 Oct 1999 15:50:56 GMT
From: merksperks@hotmail.com
Subject: Perl - login to http site
Message-Id: <7tqckt$7bq$1@nnrp1.deja.com>
I am trying to find a way to log in automatically (via a script) to a
web site that requires a login. I am using Activestate Perl 5005 build
520. I am not sure what the syntax would be. If anyone can help I'd
appreciate it.
Thanks
David
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 07 Oct 1999 14:42:12 -0400
From: Carlo Mantini <carlo.mantini@fmr.com>
Subject: Perl CGI/Browser Output Bug - Help!
Message-Id: <37FCE983.2014C864@fmr.com>
I have a unique problem with a CGI script that I have been writing. The
script runs a compiled executable and prints the output in HTML to the
browser. When I run the script from the command line, I get the proper
results. However, when I run the script from the page, I receive
"Document: Done" on my frame page, but nothing is printed. When I check
the source of the output frame page, the only thing printed are
<HTML><BODY></BODY></HTML>. Its as if the browser ignores the formatted
output from the compiled executable in the script.
The formatted output from the executable is handled via a pipe. Here it
is below:
open (CMD, "suncap $host $symbol |");
CMD->autoflush( 1);
print header (), start_html ();
while (defined($line_ = <CMD>)) {
chomp($line_);
print p("$line_"."<br>" );
}
print end_html ();
close CMD;
I have also tried printing the Content-Type command, followed by "\n"s,
and the <HTML> and <BODY> tags, and placing the print_header and
start_html commands at the start of the script with mixed results, but
never the desired one. Has anyone ever encountered this? How did you
get around it? Help!
------------------------------
Date: Sun, 10 Oct 1999 11:01:41 -0500
From: Dan Baker <dtbaker_@busprod.com>
Subject: Re: perl compiler for Win32?
Message-Id: <3800B865.36A54E4B@busprod.com>
Michael Reich wrote:
>
> I seem to remember hearing about a tool that compiled Perl scripts into
> .exe files for the Win32 platform. Can anyone give me any information as
> to what this product is and where I can find it?
----------
use dejanews and search for perl2exe
Dan
------------------------------
Date: Sat, 9 Oct 1999 23:05:53 -0400
From: <ICEMOUNTAIN@prodigy.net>
Subject: Question? Writing to file
Message-Id: <7tovu4$hde$1@newssvr04-int.news.prodigy.com>
I want to be able to write to a file but it's not working, the file path is
correct and I have it chomd 666.
Do you know what is wrong.
here is the script, its a small part of a bigger script:
#!/usr/local/bin/perl
print "Content-type:text/html\n\n";
@values = split(/\&/, $ENV{'QUERY_STRING'});
foreach $value (@values) {
($name, $data) = split(/=/, $value);
$FORM{$name} = $data;
}
if ($FORM{'action'} eq "addentrie") {
&addentrie;
}
print <<add;
<html>
<head>
<title>Glenns FD Patch Page</title>
</head>
<body>
<center>
<form method="post" action="http://www.3gc.net/cgi-bin/scripts/testrade.cgi"
style="font-size : 11px;font-family : verdana, arial;">
<table style="font-size : 11px;font-family : verdana, arial;">
<tr>
<td>
Name:
</td>
<td>
<input type="Text" name="name" size="20" maxlength="100" style="font-size
: 11px;font-family : verdana, arial;">
</td>
</tr>
<tr>
<td>
Email Address:
</td>
<td>
<input type="Text" name="email" size="20" maxlength="100"
style="font-size : 11px;font-family : verdana, arial;">
</td>
</tr>
<tr>
<td>
Interest:
</td>
<td>
<select name="interested" style="font-size : 11px;font-family : verdana,
arial;">
<option value="FD">FD</option>
<option value="PD">PD</option>
<option value="EMS">EMS</option>
</select>
</td>
</tr>
<tr>
<td valign="top">
Comments:
</td>
<td>
<textarea name="comments" cols="20" rows="5" style="font-size :
11px;font-family : verdana, arial;"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="Submit" value="Submit" style="font-size : 11px;font-family :
verdana, arial;">
</td>
</tr>
</table>
<input type="Hidden" name="action" value="addentrie">
</form>
</center>
</body>
</html>
add
sub addentrie {
open(OUTF,">>/home/3gc/www/cgi-bin/scripts/FD.txt") or &dienice("Couldn't
open FD.txt for writing: $!");
print OUTF "$FORM{'name'}|$FORM{'email'}|$FORM{'comments'}";
close(OUTF);
}
sub dienice {
print <<Die;
<html>
<head>
<title>Error</title>
</head>
<body>
$!
</body>
</html>
Die
}
Thanks For any help you can provide.
------------------------------
Date: Sat, 9 Oct 1999 14:35:07 -0500
From: "homeless" <homelessinseattle@yahoo.com>
Subject: Re: search a file on a remote server
Message-Id: <BIML3.2261$V4.10665169@typhoon.stlnet.com>
Tao Fan wrote in message ...
>[ftp stuff....] Another question, can I chmod a file remotely?
If you have an FTP session running, you can CHMOD a file with perl by
sending the following command to the command port: (21):
print $command_port_file_handle "SITE chmod $mode $file\n";
--homeless
------------------------------
Date: 10 Oct 1999 15:23:36 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Shell and Perl have different $?
Message-Id: <7tqb1o$drp$1@rguxd.viasystems.com>
Philip 'Yes, that's my address' Newton <nospam.newton@gmx.net> wrote:
:>On 8 Oct 1999 18:44:10 GMT, ilya@math.ohio-state.edu (Ilya
:>Zakharevich) wrote:
:>>> $ia = system("rcp $file_to_copy user\@machine:/path/$file_remote");
:>>> print "\$? = $? \$ia = $ia \n";
:>>
:>>I think this is more or less equivalent to
:>>
:>> (rcp file.x user@machine:/path/somedir/copy.x)
:>>
:>>Use multiarg-system() instead.
:>Does this imply that using multi-arg system puts rcp's exit status
:>into $?, whereas single-arg system puts the shell's exit status into
:>$? ? In that case, $? == 0 would (sort of) make sense for an rcp
:>failure; after all, the shell itself exited successfully (or does it
:>propage $? ?).
#!/usr/lib/lprgs/perl -w
my $rc = system('/bin/cat /tmp/not_there 2>/dev/null');
print 'passed to shell rc=', $rc, ' $?=', $?, "\n";
$rc = system('/bin/cat', '/tmp/not_there');
print 'multiarg system rc=', $rc, ' $?=', $?, "\n";
$rc = system('(/bin/cat /tmp/not_there 2>/dev/null)');
print 'passed to subshell rc=', $rc, ' $?=', $?, "\n";
__END__
passed to shell rc=512 $?=512
cat: cannot open /tmp/not_there
multiarg system rc=512 $?=512
passed to subshell rc=512 $?=512
If someone sees different behavior, then it depends on the shell.
I wouldn't know as I lead a sheltered life and get to depend on
mostly well behaved shells.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: Sat, 09 Oct 1999 16:46:16 GMT
From: xxxxx@cris.com (J. A. Mc.)
Subject: Re: tool to convert BMPs to GIFs programatically?
Message-Id: <38056ec0.3498123@news2.lvdi.net>
On 09 Oct 1999 00:14:37 -0400, Tom Lane <tgl@netcom.com> wrote:
>xxxxx@cris.com (J. A. Mc.) writes:
>> My thought was thay perhaps he could
^^^^^^
>> use the .jpg form instead, and
^^^^^^
>> explained one such usage.
>
>> No, it's NOT a party trick, just because _you_ have no use for it.
>
>Alan was making the entirely correct point that if you want to go
>from BMP to GIF, JPEG is a horrible choice of waystation.
I was not suggesting it as a 'waystation' but an alternative for
browser viewing. Please DO try reading my exact words. It was
suggested as a second OPTION!
>
>I take it _you_ have no use for actually knowing anything about the
>strengths and weaknesses of the image formats you use?
Exactly the reason why an alternative IS sometimes a good choice,
sometimes not! But at least one should consider the choices available!
>
> regards, tom lane
> organizer, Independent JPEG Group
------------------------------
Date: Sat, 09 Oct 1999 16:47:57 GMT
From: xxxxx@cris.com (J. A. Mc.)
Subject: Re: tool to convert BMPs to GIFs programatically?
Message-Id: <38067067.3921179@news2.lvdi.net>
On Sat, 9 Oct 1999 15:46:37 +0200, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:
>On Fri, 8 Oct 1999, J. A. Mc. wrote:
>
>> >An amusing party trick, but what use in this context? Images that are
>> >good for GIF or PNG representation are usually very unsuitable as JPEGs,
>> >and vice versa (see Tom Lane's JPEG FAQ).
>> >
>> This 'context' as you put it, is the original question of:
>>
>> "I want to convert some BMPs to GIFs using code, without any user
>> interaction.
>
>Exactly.
>
>> My thought was thay perhaps he could use the .jpg form instead,
>
>And the reason why not is explained by the part of my posting that you
>quoted. Thanks.
You're welcome, and you've still missed the point! <G>
Just because it's a .bmp, and the user THINKS he should use a .gif,
doesn't automatically rule out the POSSIBILITY of CONSIDERING .jpg.
The original poster NEVER said exactly what type of image he was
converting, drawing, solid color, photograph, etc.
You and Tom both jumped to the conclusion that .jpg was inappropriate
as the question was about .gif.
You assumed I meant the questioner to have to convert .bmp to .jpg to
.gif, when I never made such a statement. The .jpg (if appropriate)
would have been the end use.
TTFN
------------------------------
Date: Sat, 09 Oct 1999 16:27:24 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Trouble understanding HTML Parsing
Message-Id: <M1KL3.23322$m4.85580629@news.magma.ca>
Web Research <webresearch@indy-soft.com> wrote in:
news:BJIL3.6697$yg.196351@news.rdc1.tn.home.com
>
> Ultimately I would like to extract all the markup between the <body ?>
> </body> tags
[...]
>
> Obviously, I've overlooked something here in my searching. Can someone
> help me down the right path? Which module do I need?
>
One possibility is to adapt the regexp from perlfaq9 to your needs,
which gives something like:
--------%<----------
use strict;
my $html = do { local $/ = undef; <> };
$html =~ s/^.*<body(?:[^>'"]*|(['"]).*?\1)*>//is;
$html =~ s/^(.*)<\/body>.*$/$1/is;
# or
# $html =~ s/^(.*)<\/body(?:[^>'"]*|(['"]).*?\2)*>.*$/$1/is;
print $html;
--------%<----------
Another possibility would be to create a subclass of HTML::Filter (but
that may be overkill and is much slower than the above):
--------%<----------
use strict;
package BodyExtractor;
require HTML::Filter;
@BodyExtractor::ISA = qw(HTML::Filter);
sub start {
my $self = shift;
$self->{body_seen}++ if $_[0] eq "body";
# if you want to output the <body ...> tag
# $self->SUPER::start(@_);
}
sub end {
my $self = shift;
# if you want to output the </body> tag
# $self->SUPER::end(@_);
$self->{body_seen}-- if $_[0] eq "body";
}
sub output {
my $self = shift;
if ($self->{body_seen}) {
$self->SUPER::output(@_);
}
}
package main;
my $body_extractor = new BodyExtractor;
$body_extractor->parse_file($ARGV[0]);
--------%<----------
------------------------------
Date: Sat, 09 Oct 1999 12:51:56 -0400
From: brian@pm.org (brian d foy)
Subject: Re: Trouble understanding HTML Parsing
Message-Id: <brian-ya02408000R0910991251560001@news.panix.com>
In article <BJIL3.6697$yg.196351@news.rdc1.tn.home.com>, "Web Research" <webresearch@indy-soft.com> posted:
> Ultimately I would like to extract all the markup between the <body ?>
> </body> tags but am having great difficulty when it comes to ignoring the
> characters and markup possible such as bgcolor=, topmargin, etc in my
> regexp. I intend to conquer that, but have turned to modules since I have to
> get this thing out the door and can no longer fiddle with it.
i like to think of this is another way - deleting everything before
the <BODY ...> and after the </BODY>. it won't handle malformed
HTML, but then, neither will parsing unless you want to make a
career out of it :)
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: Sat, 09 Oct 1999 16:59:39 GMT
From: James Tolley <jtolley@bellatlantic.net>
Subject: Re: Trouble understanding HTML Parsing
Message-Id: <37FF7410.FDA5A7ED@bellatlantic.net>
Have you looked into HTML::Parser? I think it'll solve your problems.
------------------------------
Date: Sun, 10 Oct 1999 17:53:57 +0200
From: "Joe" <joe@somewhere.net>
Subject: Unique ID
Message-Id: <7tqcia$on3$1@news.inet.tele.dk>
Hi,
I need to be able to obtain a unique ID from within a program -any
suggestions as how to do this in Perl?
-Joe
------------------------------
Date: Sun, 10 Oct 1999 16:05:43 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: URLs and what they mean, was Re: Help!
Message-Id: <Pine.HPP.3.95a.991010155458.7619B-100000@hpplus01.cern.ch>
[Note to original poster - many experienced usenauts routinely disregard
postings with silly subject lines. I only read this f'up because it
was posted by a respected contributor. I don't know what the original
question was and I'm not tempted to find out: I'm only commenting on
the exchange that's quoted below.]
On 9 Oct 1999, Abigail wrote:
> David Efflandt (efflandt@xnet.com) wrote
> ** In what context? What you show here is a URL that ends with a filename,
> ** not a directory. A directory (default index) would have a trailing slash.
> ** However, you may not be aware of it because the webserver will usually
> ** redirect you to the correct URL with trailing slash.
>
> Actually, it's neither. URL point to _resources_, not files.
Strictly speaking, you are of course correct.
> http://www.something.com/anything might be mapped by the server to
> a file; not necessarely named 'anything'.
Sure.
While the statement made by Dave isn't pedantically correct, it _does_
correspond to a very widely adopted convention. And the remark about
getting redirected from 'anything' to 'anything/' is a very real
phenomenon, which probably consumes in aggregate quite a quantity of
network resources and causes delays in document presentation.
> The assumption that URLs point to files is false.
Certainly. And the URLs 'anything' and 'anything/' _could_ point
to two totally different and unrelated resources. In theory, anyhow.
It would seem perverse to do that in practice, other than as a means of
calling people's attention to the stealth-redirection issue.
Don't you agree, even if you wanted it expressed differently?
cheers
------------------------------
Date: Sun, 10 Oct 1999 17:08:20 +0000
From: Vampiloup <vampiloup@crosswinds.net>
Subject: while (<MAYA>) read 1 line of 2 ?
Message-Id: <3800C804.72BE09E6@crosswinds.net>
Sorry for my bad english.
My problem : I want read a file.
Each line write by a ' print MAYA "$a\n"; ' (one 'print' by line).
I verified : The file contain all the lines.
But if i read by this program :
*****************
while (<MAYA>){
$var = <MAYA>;
print "$var\n";
print "<br>\n";
}
*******************
The HTML result not print all lines : One yes, one no, one yes, one
no...
????????
Vampiloup
------------------------------
Date: Sun, 10 Oct 1999 11:58:56 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: while (<MAYA>) read 1 line of 2 ?
Message-Id: <3800B7C0.AE7D11EE@rochester.rr.com>
Vampiloup wrote:
>
> Sorry for my bad english.
>
> My problem : I want read a file.
> Each line write by a ' print MAYA "$a\n"; ' (one 'print' by line).
>
> I verified : The file contain all the lines.
>
> But if i read by this program :
>
> *****************
> while (<MAYA>){
> $var = <MAYA>;
Vampiloup, *each* <MAYA> in a scalar context (as both of these are)
reads a line of input. Replace the line
$var=<MAYA>;
with
$var=$_;
and you should be all set. Or just use $_ instead of $var. Note
that the <MAYA> in the while statement reads a line and places it
in variable $_ (the default scalar variable in Perl). Also, you
may want to use chomp to remove the newline at the end of the line,
since you are adding a newline in your print statement below.
Please see the I/O operators section of perlop. If you don't know
how to do that, give the command (at your command prompt)
perldoc perlop
to do this (perldoc is installed on your computer right along with
Perl). For information on chomp, type
perldoc -f chomp
And buy and read the books "Learning Perl" and "Programming Perl".
> print "$var\n";
> print "<br>\n";
> }
> *******************
>
> The HTML result not print all lines : One yes, one no, one yes, one
> no...
>
> ????????
>
> Vampiloup
------------------------------
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 V9 Issue 1031
**************************************