[13657] in Perl-Users-Digest
Perl-Users Digest, Issue: 1067 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 15:01:59 1999
Date: Fri, 15 Oct 1999 12:01:49 -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: <940014109-v9-i1067@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 15 Oct 1999 Volume: 9 Number: 1067
Today's topics:
Re: Is there an easy Perl equivalent to SSIs including <stuw@dial.pipex.yourpantscom>
Re: Is there an easy Perl equivalent to SSIs including <stuw@dial.pipex.yourpantscom>
Re: Is there an easy Perl equivalent to SSIs including <stuw@dial.pipex.yourpantscom>
Re: Is there an easy Perl equivalent to SSIs including <jeff@vpservices.com>
Re: Is there an easy Perl equivalent to SSIs including (Abigail)
Re: Is there an easy Perl equivalent to SSIs including (Stuart Wright)
Re: Is there an easy Perl equivalent to SSIs including (Stuart Wright)
Re: Is there an easy Perl equivalent to SSIs including <laurensmith@sprynet.com>
Re: Is there an easy Perl equivalent to SSIs including (Stuart Wright)
Re: Is there an easy Perl equivalent to SSIs including <gellyfish@gellyfish.com>
Re: Is there an easy Perl equivalent to SSIs including <occitan@esperanto.org>
isa_defs on Solaris2.6 lsteinha6805@my-deja.com
Re: JPL <cassell@mail.cor.epa.gov>
Just to get rid of dos prompt window. <cau.quach@sympatico.ca>
Re: Just to get rid of dos prompt window. <dchristensen@california.com>
Re: Just Two LWP::UserAgent questions (Dan)
Re: Just Two LWP::UserAgent questions (Bill Moseley)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 13 Oct 1999 13:36:22 +0100
From: "Stuart Wright" <stuw@dial.pipex.yourpantscom>
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <939818250.1916.0.nnrp-04.c2d95102@news.demon.co.uk>
First of all, thanks very much for the advice.
> > >
> > In my original post I wrote that I had considered this - but not being a
> > Perl expert (actually it baffles me - I tend to copy existing Perl and
hope
> > it works without knowing how), opening a file and printing it's contents
is
> > not *necessarily* a quick solution for some people.
> > But thanks anyway.
>
> well...what do you think happens when you do an Server-Side-Include?
> The file is opened and read, and it's contents(or results) are printed.
> This is a trivial operation. in fact, it is a simple four liner
> (although it could have even been done in two):
Ok, fair enough.
>
<snip the code>
>
> So...if you considered this and decided not to do it, what other options
> do you have? I'm curious, because there really isn't any simpler way to
> do it in PERL.
Well that is, infact the question. Is there a simpler way. As in a
function which does it.
e.g. PrintFile("filename.html")
I *had* looked through Perl resources without finding anything simpler.
When learning a language, I have found in my 20 years experience that there
is often a function which does what you want and it's worth spending some
time finding it. (Rather than re-writing it).
In some development environments, I have known of people who have rushed on
in and made the above mistake.
>
> I'm also curious about your other statement...that you "hope it works,
> without knowing how..." Does that mean you really could give a rat's
> a** about learning perl, and just want someone to do the real work for
> you?
Actually I love creating web sites, but the biggest pain in the arse is
getting the Perl scripts to work. I don't actually want to learn Perl. I
just copy other Perl scipts and tweak them until they work. I guess I got
used to 4GL windows development and I don't enjoy going back to text
programming - particularly when it is *so* unreadable to a novice.
>If this is for a company website, I must ask how you can sleep at
> night, not really knowing what all that code you use does.
Oh I know exactly what it does. I just don't know - or really care - how it
does it.
>Do you just
> blindingly trust that the code is doing what you want it to do, and
> nothing more?
Yes.
>People like you build websites that are known as
> "cracker's delights", because they're so full of bugs and backdoors.
Maybe so. But in the applications I have written (or copied) Perl for, no
harm can be done.
>
> Think of that. I could have "given" you a twenty-line code snip that
> opened a file and printed it, and also sent me all your customer
> information, set up any subsequent page to redirect through my server so
> I could steal your form data, wipe out your filesystem, give myself
> remote access to your server, and lots of other really fun stuff.
I wouldn't trust the internet with customer data, anyway, but how can you
wipe out a file system if the correct permissions are set ?
>
> I, of course, have no need for your information, so the code above is
> probably safe to use. But there's lots of bored young programmers that
> would do malicious things just for a lark.
Yeah - sad, isn't it?
>
> How would you know?
Again - the apps I have created don't hold any sensitive information.
>
> If this is something you might have to do *several times* in the future,
> wouldn't it be *quicker* to spend an hour learning it the first time, so
> that it becomes a quick little 5 minute thing NEXT time and the NEXT
> NEXT time?
You have a good point. If only it took an hour.
>
> Perhaps you're better suited to using VBscript, a Microsoft scripting
> language in which difficult things are sometimes easy to do, and simple
> things are seldom easy to do. VBscript has a command that works just
> like SSI "include", in fact it's called "include". Imagine that.
I have found the above to be true in the 4GL development language I use.
You have valid points. But when you have a site to finish and a baby
screaming for attention, sometimes the quickest route is to get the script
working and get on with something else.
Oh and of course I don't have a personal web server running (never managed
to get one working) so I develop Perl in wordpad, upload it to the site - if
it doesn't work I tweak it and upload it again etc etc. Very tedious
process.
Cheers
------------------------------
Date: Wed, 13 Oct 1999 13:37:28 +0100
From: "Stuart Wright" <stuw@dial.pipex.yourpantscom>
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <939818313.1935.0.nnrp-04.c2d95102@news.demon.co.uk>
> >#---------------------------------------------
> >#code snippet:
> >#
> >sub include_this_file {
> > my $include_file = @_; # get the name of the file
> > open (INCLUDE, "$include_file") or print "couldn't open $include_file,
> >error: $!\n";
> > while (<INCLUDE>) {print;} # read each line from the file and print
> >it.
>
> Or instead of the above while loop, simply print the whole file at once:
> print <INCLUDE>;
>
> > close (INCLUDE); # be nice and close the file yourself,
> > #even though perl will eventually do it for
> >you
> >}
Cool, thanks - I'll give it a try tonight.
------------------------------
Date: Wed, 13 Oct 1999 13:56:20 +0100
From: "Stuart Wright" <stuw@dial.pipex.yourpantscom>
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <939819445.2377.0.nnrp-04.c2d95102@news.demon.co.uk>
After the (deserved) slating from David, here, for your amusement is the
working script (with references to the actual URL removed incase you're
feeling vindictive :)
If you do feel like commenting (constructively) on the worst bits of the
code (assuming there are some bits which aren't bad) then I would appreciate
that.
#!/usr/bin/perl
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
# Split the name-value pairs
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
}
# read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>My website. Reviews archive.</TITLE>";
print "<META HTTP-EQUIV='Content-Type' CONTENT='text/html;
charset=iso-8859-1'>";
print "<META NAME='KEYWORDS' CONTENT='lots of keywords'>";
print "<META NAME='DESCRIPTION' CONTENT='Reviews and articles.'>";
print "</HEAD><BODY BGCOLOR='ffffff' TEXT='#000080'>";
print "<H1 ALIGN='CENTER'><IMG
SRC='http://mywebsite.com/reviews/images/stripes.jpg' WIDTH='50'
HEIGHT='16'><FONT FACE='Arial' COLOR='#000000'> Tried <FONT
COLOR='#FF0000'>&</FONT> Tested </FONT><IMG
SRC='http://mywebsite.com/reviews/images/stripes.jpg' WIDTH='50'
HEIGHT='16'></H1>";
print "<H3 ALIGN='CENTER'><FONT FACE='Arial' COLOR='#000080'>Home Cinema
Choice Review Archive</FONT></H3>";
$database = "reviews.txt";
# Split the name-value pairs
# @pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if ($name eq 'sort_by') {$sort_on = $value};
if ($name eq 'search_for') {$search_for = $value};
if ($name eq 'category') {$category = $value};
$search_for = "\." if $search_for eq "";
}
&resolve_category;
$cat = $category;
if ($cat ne '') {
print "<H4 ALIGN='CENTER'><FONT FACE='Arial'
COLOR='#000080'>$category_desc</FONT></H4>";
}
print "<H5 ALIGN='CENTER'><FONT FACE='Arial' COLOR='#000080'>Search
Results</FONT></H5>";
&search_database($search_for);
$count = @results;
&print_rows;
if ($search_for eq '.') {$search_for = 'all records'};
print "<P ALIGN='CENTRE'><FONT FACE='Arial' SIZE='-1'
COLOR='#000080'>Searched for <B>$search_for</B>, sorted by <B>$sort_on</B>.
Items found : $count.</FONT></P>";
print "
<BLOCKQUOTE> <P><FONT FACE='Arial' SIZE='-1' COLOR='#000080'>Notes
:</FONT></P>
<UL>
<LI><FONT FACE='Arial' SIZE='-1' COLOR='#000080'>Some notes.</FONT>
</LI>
<LI><FONT FACE='Arial' SIZE='-1' COLOR='#000080'>Some more
notes.</FONT></LI>
<LI><FONT FACE='Arial' SIZE='-1' COLOR='#000080'>Yet more notes.</FONT></LI>
</UL>
<TABLE WIDTH='50%' ALIGN='CENTER' CELLSPACING='0' CELLPADDING='0'
BORDER='0'>
<TR>
<TD WIDTH='50%'><HR>
</TD>
<TD ALIGN='CENTER' WIDTH='60'><IMG
SRC='http://www.mywebsite.com/images/logo_tiny.gif' BORDER='0'
WIDTH='50' HEIGHT='20'></TD>
<TD WIDTH='50%'><HR>
</TD>
</TR>
</TABLE>
<TABLE WIDTH='50%' ALIGN='CENTER' CELLSPACING='0' CELLPADDING='0'
BORDER='0'>
<TR>
<TD WIDTH='50%'><HR>
</TD>
<TD ALIGN='CENTER' WIDTH='60'><IMG
SRC='http://www.mywebsite.com/images/logo_tiny.gif' BORDER='0'
WIDTH='50' HEIGHT='20'></TD>
<TD WIDTH='50%'><HR>
</TD>
</TR>
</TABLE>
<P ALIGN='CENTER'><FONT SIZE='-2' COLOR='#000080' FACE='Arial'>Copy
Copyright
© 1996-1999 Me. <BR>
Web Material Copyright © 1999 Me.</FONT></P>
</BLOCKQUOTE>";
print "</BODY></HTML>";
exit;
###########################
sub search_database{
$search_it = $_[0];
$star = "<IMG SRC='http://mywebsite.com/reviews/images/star_blue.gif'
WIDTH='15' HEIGHT='13'>";
$halfstar = "<IMG
SRC='http://mywebsite.com/reviews/images/halfstar_blue.gif' WIDTH='8'
HEIGHT='13'>";
open(DB, $database);
while(<DB>){
if(/$search_it/oi && /$category/oi) {push(@results, $_)};
} # End of while.
close (DB);
} # End of subroutine.
sub print_rows{
$row_no = 0;
if ($cat ne '') {
print "<TABLE CELLSPACING='0' CELLPADDING='0' WIDTH='100%' BORDER='0'
BGCOLOR='#000080'><TR>";
print "<TH WIDTH='50%' VALIGN='TOP' ALIGN='LEFT'><FONT FACE='Arial'
SIZE='-1' COLOR='#FFFFFF'>Make and Model</FONT></TH>";
print "<TH WIDTH='15%' VALIGN='TOP' ALIGN='LEFT'><FONT FACE='Arial'
SIZE='-1' COLOR='#FFFFFF'>Score</FONT></TH>";
print "<TH WIDTH='20%' VALIGN='TOP' ALIGN='RIGHT'><FONT FACE='Arial'
SIZE='-1' COLOR='#FFFFFF'>Price</FONT></TH>";
print "<TH WIDTH='15%' VALIGN='TOP' ALIGN='RIGHT'><FONT FACE='Arial'
SIZE='-1' COLOR='#FFFFFF'>Reviewed in</FONT></TH></TR></TABLE>";
}
@sorted = ();
foreach $row
esults){
($manufacturer,$model,$rating,$bb,$price,$date,$url) = split(/\|/,$row);
if ($sort_on eq 'manufacturer') {
$key = $manufacturer;
}
elsif ($sort_on eq 'model') {
$key = $model;
}
elsif ($sort_on eq 'price') {
$key = $price;
}
elsif ($sort_on eq 'date') {
$key = $date;
}
if ($cat eq '') {
$len = length($url) - 7;
$shtml = substr($url,$len,6);
if ($shtml ne '.shtml') {
$len = length($url) - 1;
$category = substr($url,0,$len);
}
else {
($category,$dummy1,$dummy2) = split(/\//,$url);
}
$key = "$category$key";
}
$new_rec = "$key|$manufacturer|$model|$rating|$bb|$price|$date|$url";
push(@sorted, $new_rec);
}
if ($sort_on eq 'price' && $cat ne '') {
@results = sort {$a <=> $b} @sorted;
}
else {
@results = sort {$a cmp $b} @sorted;
}
foreach $row (@results){
$row_no = $row_no + 1;
($key,$manufacturer,$model,$rating,$bb,$price,$date,$url) = split(/\|/,$row);
$manufacturer=~ tr/+/ /;
$manufacturer=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$manufacturer=~ s/<!--(.
|\n)*-->//g;
# discover if the URL is full or just the category
$len = length($url) - 7;
$shtml = substr($url,$len,6);
if ($cat eq '') {
if ($shtml ne '.shtml') {
$len = length($url) - 1;
$category = substr($url,0,$len);
}
else
($category,$dummy1,$dummy2) = split(/\//,$url);
}
$category =~ s/ file://g;
&resolve_category;
if ($category ne $old_category) {
print "<H4 ALIGN='CENTER'><FONT FACE='Arial'
COLOR='#000080'>$category_desc</FONT></H4>";
print "<TABLE CELLSPACING='0' CELLPADDING='0' WIDTH='100%'
BORDER='0' BGCOLOR='#000080'><TR>";
print "<TH WIDTH='50%' VALIGN='TOP' ALIGN='LEFT'><FONT
FACE='Arial' SIZE='-1' COLOR='#FFFFFF'>Make and Model</FONT></TH>";
print "<TH WIDTH='15%' VALIGN='TOP' ALIGN='LEFT'><FONT
FACE='Arial' SIZE='-1' COLOR='#FFFFFF'>Score</FONT></TH>";
print "<TH WIDTH='20%' VALIGN='TOP' ALIGN='RIGHT'><FONT
FACE='Arial' SIZE='-1' COLOR='#FFFFFF'>Price</FONT></TH>";
print "<TH WIDTH='15%' VALIGN='TOP' ALIGN='RIGHT'><FONT
FACE='Arial' SIZE='-1' COLOR='#FFFFFF'>Reviewed
in</FONT></TH></TR></TABLE>";
$old_category = $category;
}
}
print "<TABLE CELLSPACING='0' CELLPADDING='0' WIDTH='100%' BORDER='0'";
if ($bb == 1) {
print " BGCOLOR='#DDFFDD'";
}
elsif ($row_no / 2 == int($row_no / 2)) {
print " BGCOLOR='#F4F4FF'";
}
print " ><TR><TD WIDTH='50%' VALIGN='TOP'>";
if ($shtml eq '.shtml') {
print "<A HREF='http://www.mywebsite.com/reviews/$url'><FONT
FACE='Arial' COLOR='#000080' SIZE='-1'>$manufacturer
$model</FONT></A></TD>";
}
else {
print "<FONT FACE='Arial' COLOR='#000080' SIZE='-1'>$manufacturer
$model</FONT></TD>";
}
print "<TD WIDTH='15%' VALIGN='TOP'><FONT FACE='Arial' SIZE='-1'
COLOR='#000080'>";
for ($i_loop = 1; $i_loop <= $rating; $i_loop++) {
print $star;
}
if (length($rating) > 1) {print $halfstar};
print "</FONT></TD>";
print "<TD WIDTH='20%' VALIGN='TOP' ALIGN='RIGHT'><FONT FACE='Arial'
SIZE='-1' COLOR='#000080'>£$price</FONT></TD>";
$month = substr($date,4,2);
if ($month eq "01") {
$month = "JAN";
}
elsif ($month eq "02") {
$month = "FEB";
}
elsif ($month eq "03") {
$month = "MAR";
}
elsif ($month eq "04") {
$month = "APR";
}
elsif ($month eq "05") {
$month = "MAY";
}
elsif ($month eq "06") {
$month = "JUNE";
}
elsif ($month eq "07") {
$month = "JULY";
}
elsif ($month eq "08") {
$month = "AUG";
}
elsif ($month eq "09") {
$month = "SEPT";
}
elsif ($month eq "10") {
$month = "OCT";
}
elsif ($month eq "11") {
$month = "NOV";
}
elsif ($month eq "12") {
$month = "DEC";
}
$year = substr($date,0,4);
print "<TD WIDTH='15%' VALIGN='TOP' ALIGN='RIGHT'><FONT FACE='Arial'
SIZE='-1' COLOR='#000080'>$month $year</FONT></TD></TR></TABLE>";
}
} # End of subroutine.
sub resolve_category{
$category_desc = $category;
if ($category eq "SystemControllers") {
$category_desc = "System Controllers";
}
if ($category eq "DVDPlayers") {
$category_desc = "DVD Players";
}
if ($category eq "LaserdiscPlayers") {
$category_desc = "Laserdisc Players";
}
if ($category eq "VCRs") {
$category_desc = "Video Cassette Recorders";
}
if ($category eq "SatelliteReceivers") {
$category_desc = "Sat/Digi Receivers";
}
if ($category eq "VideoGameTechnology") {
$category_desc = "Video Game Technology";
}
if ($category eq "PrologicDecoders") {
$category_desc = "Prologic Decoders";
}
if ($category eq "DolbyDigitalDecoders") {
$category_desc = "Dolby Digital Decoders";
}
if ($category eq "Processors") {
$category_desc = "DTS Decoders";
}
if ($category eq "SpeakerPackages") {
$category_desc = "Speaker Packages";
}
if ($category eq "CentreSpeakers") {
$category_desc = "Centre Speakers";
}
if ($category eq "SurroundSpeakers") {
$category_desc = "Surround Speakers";
}
if ($category eq "VideoProjectors") {
$category_desc = "Video Projectors";
}
if ($category eq "HomeCinemaSystems") {
$category_desc = "Home Cinema Systems";
}
if ($category eq "MINIMIDISystems") {
$category_desc = "MINI / MIDI Systems";
}
if ($category eq "PersonalListening") {
$category_desc = "Personal Listening";
}
if ($category eq "InternetTechnology") {
$category_desc = "Internet Technology";
}
}
------------------------------
Date: 13 Oct 1999 13:53:30 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <38048E90.253360A3@vpservices.com>
Stuart Wright wrote:
> I don't actually want to learn Perl. I just copy other Perl scipts and
> tweak them until they work.
> ...
> Oh and of course I don't have a personal web server running (never managed
> to get one working) so I develop Perl in wordpad, upload it to the site - if
> it doesn't work I tweak it and upload it again etc etc. Very tedious
> process.
Reminds me of the guy who had a stack of wood that would have taken a
day to chop with a sharp ax. He spent two days chopping it with a dull
axe because he was too busy chopping wood to take the time to sharpen
his ax.
Maybe you don't need to learn Perl, but brother, you *really* gotta
learn the meaning of false laziness. True laziness is much easier.
--
Jeff
------------------------------
Date: 13 Oct 1999 14:45:51 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <slrn809oau.nk2.abigail@alexandra.delanet.com>
Stuart Wright (stuw@dial.pipex.yourpantscom) wrote on MMCCXXXIV September
MCMXCIII in <URL:news:939819445.2377.0.nnrp-04.c2d95102@news.demon.co.uk>:
() After the (deserved) slating from David, here, for your amusement is the
() working script (with references to the actual URL removed incase you're
() feeling vindictive :)
() If you do feel like commenting (constructively) on the worst bits of the
() code (assuming there are some bits which aren't bad) then I would appreciate
() that.
()
() #!/usr/bin/perl
There is no -w
There is no -T
There is no use strict;
There is no use CGI;
Those are the worst bits. There's no point in looking at the rest.
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 14 Oct 1999 05:42:45 GMT
From: stuw@dial.pipex.com.remove.everything.after.the.com (Stuart Wright)
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <38056d1a.3091999@news.dial.pipex.com>
On 13 Oct 1999 14:45:51 -0500, abigail@delanet.com (Abigail) wrote:
>Stuart Wright (stuw@dial.pipex.yourpantscom) wrote on MMCCXXXIV September
>MCMXCIII in <URL:news:939819445.2377.0.nnrp-04.c2d95102@news.demon.co.uk>:
>() After the (deserved) slating from David, here, for your amusement is the
>() working script (with references to the actual URL removed incase you're
>() feeling vindictive :)
>() If you do feel like commenting (constructively) on the worst bits of the
>() code (assuming there are some bits which aren't bad) then I would appreciate
>() that.
>()
>() #!/usr/bin/perl
>
>There is no -w
>There is no -T
>There is no use strict;
>There is no use CGI;
>
>Those are the worst bits. There's no point in looking at the rest.
>
>
>
mmmm yeah. Not in *any* example of Perl I've seen on the Perl resource
sites is there any mention of the above stuff or it's importance.
-----
Stuart Wright stu-w@usa.net.remove.everything.after.net
Software developer,
web author for the Hi-Fi and Home Cinema industries,
drummer and fast biker.
Visit my web site http://ds.dial.pipex.com/town/road/xmk67/
------------------------------
Date: Thu, 14 Oct 1999 06:13:35 GMT
From: stuw@dial.pipex.com.remove.everything.after.the.com (Stuart Wright)
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <38067406.4863478@news.dial.pipex.com>
On 12 Oct 1999 06:03:45 GMT, efflandt@xnet.com (David Efflandt) wrote:
>>
>>#---------------------------------------------
>>#code snippet:
>>#
>>sub include_this_file {
>> my $include_file = @_; # get the name of the file
>> open (INCLUDE, "$include_file") or print "couldn't open $include_file,
>>error: $!\n";
>> while (<INCLUDE>) {print;} # read each line from the file and print
>>it.
>
>Or instead of the above while loop, simply print the whole file at once:
> print <INCLUDE>;
>
>> close (INCLUDE); # be nice and close the file yourself,
>> #even though perl will eventually do it for
>>you
>>}
After an hour, I gave up trying to get the above to work.
For a start I get server 500 error if I declare the $include_file
variable with 'my' infront of it.
Also I get the same error if I put 'or print...' after the open.
And I'm not sure how to specify the relative url of the file to
include on a virtual server. Should a fixed URL specifying
http://www.... etc work ?
Thanks.
-----
Stuart Wright stu-w@usa.net.remove.everything.after.net
Software developer,
web author for the Hi-Fi and Home Cinema industries,
drummer and fast biker.
Visit my web site http://ds.dial.pipex.com/town/road/xmk67/
------------------------------
Date: Wed, 13 Oct 1999 15:06:08 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <7u2von$89f$1@brokaw.wa.com>
Stuart Wright wrote in message <38056d1a.3091999@news.dial.pipex.com>...
>On 13 Oct 1999 14:45:51 -0500, abigail@delanet.com (Abigail) wrote:
>>() #!/usr/bin/perl
>>
>>There is no -w
>>There is no -T
>>There is no use strict;
>>There is no use CGI;
>mmmm yeah. Not in *any* example of Perl I've seen on the Perl resource
>sites is there any mention of the above stuff or it's importance.
This is as good a time to find out about them than any, then.
-w turns warnings on. A lot of problems that would pass undetected
without it (uninitialized variables being the one I run into most often)
are announced when they are encountered.
perldoc -q debug
-T turns on taint checking. Read perlsec for more information.
perldoc -q taint
perldoc perlsec
strict turns on compile time warnings, disallowing global variables and
a host of other things that can cause trouble.
perldoc strict
CGI.pm is the "all-singing, all-dancing" CGI module. It's your WWW
Express card, Don't program CGI without it.
perldoc cgi
:-)
Lauren
------------------------------
Date: Thu, 14 Oct 1999 14:59:59 GMT
From: stuw@dial.pipex.com.remove.everything.after.the.com (Stuart Wright)
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <3805efb5.1742523@news.dial.pipex.com>
On Wed, 13 Oct 1999 15:06:08 -0700, "Lauren Smith"
<laurensmith@sprynet.com> wrote:
>
>Stuart Wright wrote in message <38056d1a.3091999@news.dial.pipex.com>...
>>On 13 Oct 1999 14:45:51 -0500, abigail@delanet.com (Abigail) wrote:
>>>() #!/usr/bin/perl
>>>
>>>There is no -w
>>>There is no -T
>>>There is no use strict;
>>>There is no use CGI;
>
>
>>mmmm yeah. Not in *any* example of Perl I've seen on the Perl resource
>>sites is there any mention of the above stuff or it's importance.
>This is as good a time to find out about them than any, then.
>
>-w turns warnings on. A lot of problems that would pass undetected
>without it (uninitialized variables being the one I run into most often)
>are announced when they are encountered.
>perldoc -q debug
>
>-T turns on taint checking. Read perlsec for more information.
>perldoc -q taint
>perldoc perlsec
>
>strict turns on compile time warnings, disallowing global variables and
>a host of other things that can cause trouble.
>perldoc strict
>
>CGI.pm is the "all-singing, all-dancing" CGI module. It's your WWW
>Express card, Don't program CGI without it.
>perldoc cgi
>
>:-)
>Lauren
>
Thanks - I'll go check up on it. You have a much better attitude than
that Abigail person.
-----
Stuart Wright stu-w@usa.net.remove.everything.after.net
Software developer,
web author for the Hi-Fi and Home Cinema industries,
drummer and fast biker.
Visit my web site http://ds.dial.pipex.com/town/road/xmk67/
------------------------------
Date: 14 Oct 1999 11:26:08 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <3805afc0_2@newsread3.dircon.co.uk>
Stuart Wright <stuw@dial.pipex.com.remove.everything.after.the.com> wrote:
> On 13 Oct 1999 14:45:51 -0500, abigail@delanet.com (Abigail) wrote:
>
>>Stuart Wright (stuw@dial.pipex.yourpantscom) wrote on MMCCXXXIV September
>>MCMXCIII in <URL:news:939819445.2377.0.nnrp-04.c2d95102@news.demon.co.uk>:
>>() After the (deserved) slating from David, here, for your amusement is the
>>() working script (with references to the actual URL removed incase you're
>>() feeling vindictive :)
>>() If you do feel like commenting (constructively) on the worst bits of the
>>() code (assuming there are some bits which aren't bad) then I would appreciate
>>() that.
>>()
>>() #!/usr/bin/perl
>>
>>There is no -w
>>There is no -T
>>There is no use strict;
>>There is no use CGI;
>>
>>Those are the worst bits. There's no point in looking at the rest.
>>
>>
>>
> mmmm yeah. Not in *any* example of Perl I've seen on the Perl resource
> sites is there any mention of the above stuff or it's importance.
So dont go to those resource sites. It has been discussed in another
current thread about trusting any old code you find on the web - this
newsgroup is a possibly better source of information as any bogus advice
is likely to be spotted and corrected.
/J\
--
"The internet is like a car boot sale" - Jon Sopel, BBC News
------------------------------
Date: Thu, 14 Oct 1999 21:12:19 GMT
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <7u5gv6$8q9$1@nnrp1.deja.com>
In article <939819445.2377.0.nnrp-04.c2d95102@news.demon.co.uk>,
"Stuart Wright" <stuw@dial.pipex.yourpantscom> wrote:
> After the (deserved) slating from David, here, for your amusement is
> the working script (with references to the actual URL removed incase
> you're feeling vindictive :)
> If you do feel like commenting (constructively) on the worst bits of
> the code (assuming there are some bits which aren't bad) then I would
> appreciate that
Perl scripts like this one, with lots of print statements, tend to be
illegible. And they can't be handled by HTML editors. If you prefer
the below script (as incomplete as the code you sent, but with fully the
same functionality), take a look at my http://beam.to/iPerl which can
handle such Perl embedded in (among others) HTML. And it also offers
the include function you were originally looking for.
Depending on the style you use, you can replace <script runat=server
language=perl>...</script> with my favourite (not HTML-conformant)
!{...}!, and !... for single lines, or other styles yet.
-- Daniel
<HTML><HEAD><TITLE>My website. Reviews archive.</TITLE>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=iso-8859-1'>
<META NAME='KEYWORDS' CONTENT='lots of keywords'>
<META NAME='DESCRIPTION' CONTENT='Reviews and articles.'>
</HEAD>
<BODY BGCOLOR='ffffff' TEXT='#000080'>
<H1 ALIGN='CENTER'><IMG
SRC='http://mywebsite.com/reviews/images/stripes.jpg' WIDTH='50'
HEIGHT='16'><FONT FACE='Arial' COLOR='#000000'> Tried <FONT
COLOR='#FF0000'>&</FONT>
Tested </FONT><IMG SRC='http://mywebsite.com/reviews/images/stripes.jpg'
WIDTH='50'
HEIGHT='16'></H1>
<H3 ALIGN='CENTER'><FONT FACE='Arial' COLOR='#000080'>Home Cinema Choice
Review
Archive</FONT></H3>
<script runat=server language=perl>
$database = "reviews.txt";
$sort_on = param( 'sort_by' );
$search_for = param( 'search_for' ) || "\.";
$category = param( 'category' );
&resolve_category;
$cat = $category;
if ($cat) {
</script>
<H4 ALIGN='CENTER'><FONT FACE='Arial'
COLOR='#000080'>$category_desc</FONT></H4>
<script runat=server language=perl>
}
</script>
<H5 ALIGN='CENTER'><FONT FACE='Arial' COLOR='#000080'>Search
Results</FONT></H5>
<script runat=server language=perl>
sub search_database{
$search_it = $_[0];
$star = "<IMG
SRC='http://mywebsite.com/reviews/images/star_blue.gif' WIDTH='15'
HEIGHT='13'>";
$halfstar = "<IMG
SRC='http://mywebsite.com/reviews/images/halfstar_blue.gif' WIDTH='8'
HEIGHT='13'>";
open(DB, $database);
while(<DB>){
if(/$search_it/oi && /$category/oi) {push(@results, $_)};
} # End of while.
close (DB);
} # End of subroutine.
&search_database($search_for);
$count = @results;
&print_rows;
if ($search_for eq '.') {$search_for = 'all records'};
</script>
<P ALIGN='CENTRE'><FONT FACE='Arial' SIZE='-1' COLOR='#000080'>Searched
for
<B>&<$search_for>;</B>, sorted by <B>&<$sort_on>;</B>. Items found :
&<$count>;.</FONT></P>
<BLOCKQUOTE> <P><FONT FACE='Arial' SIZE='-1'
COLOR='#000080'>Notes:</FONT></P>
<UL>
<LI><FONT FACE='Arial' SIZE='-1' COLOR='#000080'>Some notes.</FONT>
</LI>
<LI><FONT FACE='Arial' SIZE='-1' COLOR='#000080'>Some more
notes.</FONT></LI>
<LI><FONT FACE='Arial' SIZE='-1' COLOR='#000080'>Yet more
notes.</FONT></LI> </UL>
<TABLE WIDTH='50%' ALIGN='CENTER' CELLSPACING='0' CELLPADDING='0'
BORDER='0'>
<TR>
<TD WIDTH='50%'><HR>
</TD>
<TD ALIGN='CENTER' WIDTH='60'><IMG
SRC='http://www.mywebsite.com/images/logo_tiny.gif' BORDER='0'
WIDTH='50' HEIGHT='20'></TD>
<TD WIDTH='50%'><HR>
</TD>
</TR>
</TABLE>
<TABLE WIDTH='50%' ALIGN='CENTER' CELLSPACING='0' CELLPADDING='0'
BORDER='0'>
<TR>
<TD WIDTH='50%'><HR>
</TD>
<TD ALIGN='CENTER' WIDTH='60'><IMG
SRC='http://www.mywebsite.com/images/logo_tiny.gif' BORDER='0'
WIDTH='50' HEIGHT='20'></TD>
<TD WIDTH='50%'><HR>
</TD>
</TR>
</TABLE>
<P ALIGN='CENTER'><FONT SIZE='-2' COLOR='#000080' FACE='Arial'>Copy
Copyright
© 1996-1999 Me. <BR>
Web Material Copyright © 1999 Me.</FONT></P>
</BLOCKQUOTE></BODY></HTML>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 14 Oct 1999 14:55:05 GMT
From: lsteinha6805@my-deja.com
Subject: isa_defs on Solaris2.6
Message-Id: <7u4qs3$moq$1@nnrp1.deja.com>
Help! We have Solaris2.6 with perl5.005. We recently recompiled perl
and upgraded the unix box to 2.6. After putting perl back out, we are
now having problems with the isa_defs.h file dying. First, the h2ph
put 2x double quotes in each die string. Fixing that, now there is no
defined value for the isa_defs to fix on. Anyone have a solution?
Lyle Steinhardt
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 12 Oct 1999 15:35:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: JPL
Message-Id: <3803B7A7.5A787E9C@mail.cor.epa.gov>
sp00fD wrote:
>
> Anyone know where I can get info on JPL? An online HOW-TO or FAQ or
> something would do...
Try the O'Reilly website. www.oreilly.com
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 14 Oct 1999 20:45:00 GMT
From: Guo Quin <cau.quach@sympatico.ca>
Subject: Just to get rid of dos prompt window.
Message-Id: <380640CC.FB326CA6@sympatico.ca>
Hello. Please answer one of following questions.
1/How can I add --more-- to "perldoc -f xxxx and/or perdoc -q xxxx"
(MSWindows) ?
or
2/How can I "perldoc (as above) > text_file" (MSwindows) ?
or
3/How to put "perldoc (as above)" in a perl script to print output in
www
browser ?
3 thanks still get 1 thanks =)
Quan
------------------------------
Date: Thu, 14 Oct 1999 14:18:51 -0700
From: "David Christensen" <dchristensen@california.com>
Subject: Re: Just to get rid of dos prompt window.
Message-Id: <38064562_1@news5.newsfeeds.com>
Quan:
For a standard installation of ActivePerl, point your browser at:
C:\Perl\html\index.html
--
David Christensen
dchristensen@california.com
Guo Quin wrote in message <380640CC.FB326CA6@sympatico.ca>...
>Hello. Please answer one of following questions.
>
>1/How can I add --more-- to "perldoc -f xxxx and/or perdoc -q
xxxx"
>(MSWindows) ?
>or
>2/How can I "perldoc (as above) > text_file" (MSwindows) ?
>or
>3/How to put "perldoc (as above)" in a perl script to print output
in
>www
>browser ?
>
>3 thanks still get 1 thanks =)
>
>Quan
>
>
>
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 14 Oct 1999 02:45:02 GMT
From: dan@galaxymall.com (Dan)
Subject: Re: Just Two LWP::UserAgent questions
Message-Id: <38054332.37748448@news.uswest.net>
On Sun, 10 Oct 1999 08:20:09 -0700, moseley@best.com (Bill Moseley)
wrote:
>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.
Register a callback subroutine that dies after you get some content.
This will abort the transfer - but you should have your headers by
then.
>--
>Bill Moseley mailto:moseley@best.com
>pls note the one line sig, not counting this one.
------------------------------
Date: Thu, 14 Oct 1999 09:48:49 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Just Two LWP::UserAgent questions
Message-Id: <MPG.126fa94bbdbcbd75989803@nntp1.ba.best.com>
Dan (dan@galaxymall.com) seems to say...
> >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.
>
> Register a callback subroutine that dies after you get some content.
> This will abort the transfer - but you should have your headers by
> then.
Thanks, that's a good idea.
I see that doesn't work if you want to wait for all the extra headers
LWP pulls out of the document, such as Title: or X-Meta. In those cases
I guess I can die after seeing the header I want, see <BODY>, or just
after some amount of content has gone by.
Thanks again,
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
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 1067
**************************************