[22135] in Perl-Users-Digest
Perl-Users Digest, Issue: 4356 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 7 06:05:38 2003
Date: Tue, 7 Jan 2003 03:05:08 -0800 (PST)
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, 7 Jan 2003 Volume: 10 Number: 4356
Today's topics:
Re: finding largest repreat value in an array (Anno Siegel)
Re: insert newlines in a long string (Tony L. Svanstrom)
Re: insert newlines in a long string <kasp@epatra.com>
Re: insert newlines in a long string (Tad McClellan)
Re: insert newlines in a long string <kasp@epatra.com>
Re: Need help with split <Jodyman@hotmail.com>
Re: Need help with split news@roaima.freeserve.co.uk
Re: Need help with split (Joe Smith)
newbie ask regexp <ie_qjzhu@yahoo.ie>
Re: newbie ask regexp <ie_qjzhu@yahoo.ie>
Re: newbie ask regexp <tassilo.parseval@post.rwth-aachen.de>
Re: Noob: Variable is getting reset, but why? (Joe Smith)
Re: print form from script (Tad McClellan)
Re: Printing to webpage (Helgi Briem)
RE madness <ah@siol.net>
reading output of tar in blocks <mzawadzk@man.poznan.pl>
Re: regexp question <someone@microsoft.com>
Regular expression for stopword removal <fergus.toolan@ucd.ie>
Re: Regular expression for stopword removal <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Regular expression for stopword removal <fergus.toolan@ucd.ie>
Re: Running CGI scripts offline (Tad McClellan)
Re: String Terminator "EndHTML" Error <stevenm@blackwater-pacific.com>
Re: top-posting (was Re: regexp question) (Helgi Briem)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Jan 2003 09:11:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: finding largest repreat value in an array
Message-Id: <ave5kn$t5c$1@mamenchi.zrz.TU-Berlin.DE>
Michael Budash <mbudash@sonic.net> wrote in comp.lang.perl.misc:
> In article <3E1A2B58.5020501@geoinformex.com>,
> hugo <hugo@geoinformex.com> wrote:
>
> > Hi
> >
> > I have an array which often contains the same values, i.e.
> >
> > myArray[0] = "a";
> > myArray[1] = "b";
> > myArray[2] = "b";
> > myArray[3] = "c";
> > myArray[4] = "c";
> > myArray[5] = "c";
> > myArray[6] = "c";
> >
> > I would like to find the greatest number of identical values in this
> > array, which, in the above example is 4, as there are 4 values "c".
> >
> > I have tried this using a loop, i.e.
> >
> > for ($i =0; $i < @myArray; $i++) {
> > if (myArray[$i] eq myArray[$i -1]) {
> > $repeat++;
> > }
> > }
> >
> > But this does not work as repeat will also add to itself when the array
> > contains "b", in the example above.
> >
> > Can anyone help? Any help, particularly a code example, will be greatly
> > appreciated.
> >
> > Thanks
> >
> > Hugo
>
> you don't say what to do if two or more have the same numbers of
> occurences, but ... here is one way:
>
> my @myarray = qw/a b b c c c c/;
>
> my %myhash;
>
> $myhash{$_}++ foreach @myarray;
>
> print "greatest is: ",
> (sort { $myhash{$b} <=> $myhash{$a} } keys %myhash)[0]
^
comma is missing here
> "\n";
Sorting is generally not the best way to find a maximum.
my ( $top, $max) = each %myhash;
while ( my ( $key, $freq) = each %myhash ) {
( $top, $max) = ( $key, $freq) if $freq > $max;
}
print "Most frequent key is $top\n";
It's more code, and not necessarily faster for small problems,
but it finds the maximum in a single pass over n keys. Sorting
takes n*log n time and will be slower for large n.
Anno
------------------------------
Date: Tue, 07 Jan 2003 05:34:15 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: insert newlines in a long string
Message-Id: <1foekpc.1xsl9me1g2yk94N%tony@svanstrom.com>
steven farris <sfarris9@insightbb.com> wrote:
> Hello, how could i take a long string in perl
> and insert newlines at the whitespace nearest
> to 80 chars? So a string that contains 320 chars
> would have roughly 5 newlines inserted into
> it.
Damn, the PPT-version of fmt isn't done yet... ;-D
<URL: http://www.perl.com/language/ppt/src/fmt/index.html >
/t
--
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #
perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'
------------------------------
Date: Tue, 7 Jan 2003 11:15:27 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Re: insert newlines in a long string
Message-Id: <avdpoh$oim$1@newsreader.mailgate.org>
[snipped]
> : I think what you need exactly is that whatever be the whitespace just
> : before/closest to 80 character (column margin), it should be replaced by
> : \n...Right?
>
> What should happen when there is a substring of eighty or more
> characters that is not broken by whitespace?
In such a case, we should break the 'long' word at 79 characters, put a
hyphen as the 80 character and continue processing it.
Any other solutions for this??
--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
-- Larry Wall in the perl man page
------------------------------
Date: Tue, 7 Jan 2003 00:01:51 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: insert newlines in a long string
Message-Id: <slrnb1kraf.ekf.tadmc@magna.augustmail.com>
Kasp <kasp@epatra.com> wrote:
> --
> Perl is designed to give you several ways to do anything, so
> consider picking the most readable one.
> -- Larry Wall in the perl man page
^^^^
^^^^
That is in the perlstyle man page nowadays.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 7 Jan 2003 12:34:42 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Re: insert newlines in a long string
Message-Id: <avdui3$q0u$1@newsreader.mailgate.org>
[snip]
> > --
> > Perl is designed to give you several ways to do anything, so
> > consider picking the most readable one.
> > -- Larry Wall in the perl man page
> ^^^^
> ^^^^
> That is in the perlstyle man page nowadays.
[snip]
Hi Tad,
I got this from http://www.perl.com/CPAN/misc/lwall-quotes.txt.gz
and it says....
%%
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
-- Larry Wall in the perl man page
%%
but from www.google.com I found that it's also mentioned in perlstyle.
So my _new_ signature should be free from controversy now :-)
--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
-- Larry Wall
------------------------------
Date: Tue, 07 Jan 2003 05:28:48 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: Need help with split
Message-Id: <kAtS9.20841$9N5.1871632@newsread2.prod.itd.earthlink.net>
<news@roaima.freeserve.co.uk> wrote in message
> Tad McClellan <tadmc@augustmail.com> wrote:
> >> Further, UNIX type filesystems can include \ as a valid filename
> >> character:
>
> > I seem to remember that there are only 2 ASCII characters
> > that are not allowed in a *nix filename: slash and NUL
>
> That feels about right. The OP's RE, even if it had had the | in the right
> place, would have also broken on at least one of my example filenames.
I stand by my final answer for even the four\five filename in unix:
#!c:\perl\bin\perl
use strict;
my $filename1 = '/home/jodyman/pics/test.jpg';
my $filename2 = '/home/001/pics/012.jpg';
my $filename3 = '/home/test';
my $filename4 = '/four\five';
my $filename5 = '/home/test of file';
my $base = base($filename1);
print "\$base = $base\n";
$base = base($filename2);
print "\$base = $base\n";
$base = base($filename3);
print "\$base = $base\n";
$base = base($filename4);
print "\$base = $base\n";
$base = base($filename5);
print "\$base = $base\n";
sub base {
my $rf = shift(@_); my $wf;
$wf = reverse($rf);
($rf) = $wf =~ /(^.+?)[\/]/;
$wf = reverse($rf);
return $wf
}
Have fun! Enjoy Perl.
Jody
PS - for windows: ($rf) = $wf =~ /(^.+?)[\\]/;
------------------------------
Date: Tue, 7 Jan 2003 09:38:19 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: Need help with split
Message-Id: <b67eva.de2.ln@moldev.cmagroup.co.uk>
Jodyman <Jodyman@hotmail.com> wrote:
> sub base {
> [...]
> ($rf) = $wf =~ /(^.+?)[\/]/;
> PS - for windows: ($rf) = $wf =~ /(^.+?)[\\]/;
There's the nub. You've written a script that appears to be intended
for both UNIX and Windows filesystems, but you need a program change
(or additional visible code complexity) to handle this differentiation.
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Tue, 07 Jan 2003 10:22:27 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: Need help with split
Message-Id: <DTxS9.1778$io.80756@iad-read.news.verio.net>
In article <kAtS9.20841$9N5.1871632@newsread2.prod.itd.earthlink.net>,
Jodyman <Jodyman@hotmail.com> wrote:
>I stand by my final answer for even the four\five filename in unix:
>my $filename3 = '/home/test';
>my $filename4 = '/four\five';
Your sub fails for "$filename4 = 'four\five'";
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Tue, 7 Jan 2003 17:15:17 -0800
From: "qjzhu" <ie_qjzhu@yahoo.ie>
Subject: newbie ask regexp
Message-Id: <ave5tc$cq2$1@mail.cn99.com>
dear all,
suppose that there is two kinds of token,
the one is string: 'N/A'
the other is amount of money, say: \$[\d,.]+
now these two tokens may appear anywhere is a string,
for example 'poiN/Abwa$ueaa$20.12rbba;lN/Aadbskdf'
^^^ ^^^^^^ ^^^
1 2 3
now how can I find the first position of any of the
two token, and save both the token (N/A in this example)
and the rest of the string (bwa$ueaa$20.12rbba;lN/Aadbskdf)?
thanks
------------------------------
Date: Tue, 7 Jan 2003 17:17:37 -0800
From: "qjzhu" <ie_qjzhu@yahoo.ie>
Subject: Re: newbie ask regexp
Message-Id: <ave61t$d02$1@mail.cn99.com>
"qjzhu" <ie_qjzhu@yahoo.ie> wrote in message
news:ave5tc$cq2$1@mail.cn99.com...
> dear all,
> suppose that there is two kinds of token,
> the one is string: 'N/A'
> the other is amount of money, say: \$[\d,.]+
>
> now these two tokens may appear anywhere is a string,
sorry, typo here :anywhere in a string,
> for example 'poiN/Abwa$ueaa$20.12rbba;lN/Aadbskdf'
> ^^^ ^^^^^^ ^^^
> 1 2 3
> now how can I find the first position of any of the
> two token, and save both the token (N/A in this example)
> and the rest of the string (bwa$ueaa$20.12rbba;lN/Aadbskdf)?
>
> thanks
>
>
>
>
------------------------------
Date: 7 Jan 2003 10:00:53 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: newbie ask regexp
Message-Id: <ave8gl$soo$1@nets3.rz.RWTH-Aachen.DE>
Also sprach qjzhu:
> dear all,
> suppose that there is two kinds of token,
> the one is string: 'N/A'
> the other is amount of money, say: \$[\d,.]+
>
> now these two tokens may appear anywhere is a string,
> for example 'poiN/Abwa$ueaa$20.12rbba;lN/Aadbskdf'
> ^^^ ^^^^^^ ^^^
> 1 2 3
> now how can I find the first position of any of the
> two token, and save both the token (N/A in this example)
> and the rest of the string (bwa$ueaa$20.12rbba;lN/Aadbskdf)?
Use a pattern match in list-context:
my $string = 'poiN/Abwa$ueaa$20.12rbba;lN/Aadbskdf';
my ($first, $remainder) = $string =~ m!(N/A|\$[\d,.]+)(.*)!;
print "$first : $remainder";
It looks for either 'N/A' or something matching '\$[\d,.]+', stores that
in $first and stores anything that follows in $remainder. It uses two
capturing pairs of parens to do that.
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Tue, 07 Jan 2003 09:35:08 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: Noob: Variable is getting reset, but why?
Message-Id: <gbxS9.1775$io.80624@iad-read.news.verio.net>
In article <brgj1vo47c1mo2ta8r4o0fq697bchaudnk@4ax.com>,
Jack Straw <jackstraw@witchita> wrote:
># read dump of all versions
>open (INPUT, $ARGV[0]) or die "Couldn't open input file.\n";
>while (<INPUT>){
> ...
>}
Don't open $ARGV[0] like that. The while(<INPUT>) statement does an
implicit open() of each file named on the command line.
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Tue, 7 Jan 2003 00:06:44 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: print form from script
Message-Id: <slrnb1krjk.ekf.tadmc@magna.augustmail.com>
Butch <webmaster@2clones.com> wrote:
> I'm teaching myself Perl and started what I thought was a simple
> project but am stuck.
Perl is not CGI.
> I want to call the script to have it print a
> form from a sub routine but cannot get it to work.
Try running your program from the command line.
> If I call *sub
> form* in the script using &form; it works but when I try to call it
> from the browser using /script.pl?action=form I get a server error.
perldoc -q "server error"
You don't have a Perl question. You have a CGI question. You
should ask CGI questions in the CGI newsgroup:
comp.infosystems.www.authoring.cgi
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 07 Jan 2003 10:32:45 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Printing to webpage
Message-Id: <3e1aac0b.285961881@news.cis.dfn.de>
On Mon, 06 Jan 2003 12:02:02 -0800, 'Captain' Kirk DeHaan
<captkirk2REMOVEME@mindspring.com> wrote:
>I'm a newbie to Perl.
That doesn't make any difference. Your question has
*nothing* to do with Perl.
>I am trying to output some info to a webpage but keep getting server
>errors. I need to make sure I am attempting to do things the right
>way.
>
>Do I need to output data to a FORM on the page using GET/POST?
I am going to have mercy on you and quote one
of the *uncountable myriads* of responses to
the endless off-topic questions on this subject:
The following is by Tad McLellan, the most friendly and
helpful person in the world if you approach him
properly:
The Perl FAQ is your friend, but you have to look there
before you can see its answers.
perldoc -q CGI
"How can I make my CGI script more efficient?"
"Where can I learn about CGI or Web programming in
Perl?"
"My CGI script runs from the command line but not the
browser."
"How can I get better error messages from a CGI
program?"
"How do I make sure users can't enter values into a
form that cause my CGI script to do bad things?"
"How do I decode a CGI form?"
> the receipt of the POST message from the HTML form.
The CGI.pm module can help with that:
perldoc CGI
> I am a newbie to Perl, so any help would be appreciated.
Ask Perl questions here.
If you have questions about CGI rather than about Perl, then
ask them in a CGI newsgroup such as:
comp.infosystems.www.advocacy
comp.infosystems.www.announce
comp.infosystems.www.authoring.cgi <===
comp.infosystems.www.authoring.html
comp.infosystems.www.authoring.images
comp.infosystems.www.authoring.misc
comp.infosystems.www.authoring.site-design
comp.infosystems.www.authoring.stylesheets
comp.infosystems.www.authoring.tools
comp.infosystems.www.browsers.mac
comp.infosystems.www.browsers.misc
comp.infosystems.www.browsers.ms-windows
comp.infosystems.www.browsers.x
comp.infosystems.www.misc
comp.infosystems.www.servers.mac
comp.infosystems.www.servers.misc
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.servers.unix <===
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Tue, 07 Jan 2003 09:56:07 GMT
From: andrej hocevar <ah@siol.net>
Subject: RE madness
Message-Id: <slrnb1lj6h.4uq.ah@sonet.utopija.linux>
Hello,
I was wondering whether there's a way of saying "neither/nor"
instead of "either/or" with a positive match. I've been playing
with these:
!~ /^(?:red|blue)$/
which works -- it means not the word "red" or "blue".
But then, is there a way of writing it similar to this (which
doesn't work)?
=~ /^[^(?:red|blue)]$/
Maybe with the "(?!)" construct? How does it work? What is wrong
with the above?
Thanks,
andrej
--
bash -c 'echo "I wish I was a JOPH."'
------------------------------
Date: Tue, 7 Jan 2003 11:15:39 +0100
From: Marek Zawadzki <mzawadzk@man.poznan.pl>
Subject: reading output of tar in blocks
Message-Id: <Pine.GSO.4.44.0301071114390.6526-100000@rose.man.poznan.pl>
Hello,
I'm creating a large tar file and I want to read tar's output, split it
into fragments and send each fragment to the remote site without making
local copy for the entire tarball (thus split command doesn't suit me).
I need something like this:
while (read(`tar -cf - local_file`), $buffer, $BLOCK_SIZE) {
do_something_with_buffer;
}
I'll appreciate any hints,
-marek
(also posted on alt.perl)
------------------------------
Date: Tue, 7 Jan 2003 19:13:29 +1100
From: "C3" <someone@microsoft.com>
Subject: Re: regexp question
Message-Id: <3e1a8b80$0$21614$afc38c87@news.optusnet.com.au>
Thanks for that. For some reason I'd forgotten that ^ was used for negation
as well. I'd gotten so used to using it for the start of the line.
------------------------------
Date: Tue, 07 Jan 2003 10:34:28 +0000
From: Fergus Toolan <fergus.toolan@ucd.ie>
Subject: Regular expression for stopword removal
Message-Id: <3E1AAD34.5040106@ucd.ie>
Hi all,
I'm a newbie with regular expressions and would be very grateful for any
help with the problem below.
I'm writing an Information Retrieval System using PERL. I'm trying to
remove stopwords from the text I have.
In the following code snippets $text is the document contents and
$stopword is the word I'm trying to remove.
My first attempt was just
$text =~ s/$stopword//ig;
Of course this removed all occurrences of the stopword from the text
including any occurrences of a stopword in another word in the text.
So for instance every letter 'a' in the text was removed.
Next I tried
$text =~ s/\ $stopword\ /\ /ig;
To replace space word space with a space character.
However this does not work for the first word as there is no space
before hand.
I tried using just a space after the stopword but this would
occassionally remove the end of a word EG: "in" is a stopword so the
word "maintain" became "mainta" which is unaceptable.
Finally I tried
$text =~ s/\ $stopword\ /\ /ig;
$text =~ s/^$stopword\ /\ /ig;
hoping to combine the two methods.
This however just removed the first word if that was a stopword.
Also if anyone knows of any good introductory web resources to regular
expressions I would be grateful if you could send them on.
Thanks in advance
Fergus
--------------------
Fergus Toolan
Intelligent Information Retrieval Group
University College Dublin
Ireland
------------------------------
Date: Tue, 7 Jan 2003 10:42:23 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Regular expression for stopword removal
Message-Id: <aveaue$90e$1@korweta.task.gda.pl>
In article <3E1AAD34.5040106@ucd.ie>, Fergus Toolan wrote:
> Hi all,
> I'm a newbie with regular expressions and would be very grateful for any
> help with the problem below.
>
> I'm writing an Information Retrieval System using PERL. I'm trying to
> remove stopwords from the text I have.
>
> In the following code snippets $text is the document contents and
> $stopword is the word I'm trying to remove.
>
> My first attempt was just
>
> $text =~ s/$stopword//ig;
>
> Of course this removed all occurrences of the stopword from the text
> including any occurrences of a stopword in another word in the text.
> So for instance every letter 'a' in the text was removed.
>
> Next I tried
>
> $text =~ s/\ $stopword\ /\ /ig;
[multiple attempts removed]
Try:
$text =~ s/\b$stopword\b//ig;
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Tue, 07 Jan 2003 11:01:13 +0000
From: Fergus Toolan <fergus.toolan@ucd.ie>
Subject: Re: Regular expression for stopword removal
Message-Id: <3E1AB379.50509@ucd.ie>
Bernard El-Hagin wrote:
> In article <3E1AAD34.5040106@ucd.ie>, Fergus Toolan wrote:
>
>>Hi all,
>>I'm a newbie with regular expressions and would be very grateful for any
>>help with the problem below.
>>
>>I'm writing an Information Retrieval System using PERL. I'm trying to
>>remove stopwords from the text I have.
>>
>>In the following code snippets $text is the document contents and
>>$stopword is the word I'm trying to remove.
>>
>>My first attempt was just
>>
>> $text =~ s/$stopword//ig;
>>
>>Of course this removed all occurrences of the stopword from the text
>>including any occurrences of a stopword in another word in the text.
>>So for instance every letter 'a' in the text was removed.
>>
>>Next I tried
>>
>> $text =~ s/\ $stopword\ /\ /ig;
>
>
>
> [multiple attempts removed]
>
>
> Try:
>
>
> $text =~ s/\b$stopword\b//ig;
>
>
> Cheers,
> Bernard
> --
> echo 42|perl -pe '$#="Just another Perl hacker,"'
Thanks a million Bernard,
That's working perfectly now.
Fergus
------------------------------
Date: Tue, 7 Jan 2003 00:13:12 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Running CGI scripts offline
Message-Id: <slrnb1krvo.ekf.tadmc@magna.augustmail.com>
Cmps <cmps7331@hotmail.com> wrote:
> My question involves running CGI scripts while offline.
Either:
1) install a web server and configure it for CGI
or
2) run your program from the command line, redirect the output
to a file, and File->Open the file in your browser
> The problem is when I am not
> connected and try to run a CGI script by loading it in the browser,
CGI programs are not executed by the browser, they are executed
on a *server*.
> It will only work uploading the file to
> CGI-BIN and calling it from there. No other directory.
That is what it is supposed to do, assuming a well-configured server.
> Besides using the
> ActivePerl from the MS-DOS prompt to just test it with no graphical
> interface,
What do you need a GUI for?
> is there some kind of options to set in the Internet Explorer to
> run scripts correctly?
CGI programs are not executed by the browser, they are executed
on a *server*.
> Is there a quick and easy Win32 MicroSoft Visual
> Studio like compiler to run Perl scripts?
Type the name of the program at a command line.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 07 Jan 2003 01:27:35 -0800
From: Steven May <stevenm@blackwater-pacific.com>
Subject: Re: String Terminator "EndHTML" Error
Message-Id: <ave64v$s0d$2@quark.scn.rain.com>
Jason wrote:
> I really need some help. I've poured over this script a million times
> lookings for missing quote marks, and checking the end for extra
> spaces, and it still doesn't work. I don't know a bunch about cgi
> scripts, so if it's a stupid mistake, I'm sorry. If anyone can figure
> out my problem, I'd be super stoked. The script is below.
>
> Thanks,
> Jason
>
> #!/usr/bin/perl
>
> # ensure all fatals go to browser during debugging and set-up
> # comment this BEGIN block out on production code for security
> BEGIN {
> $|=1;
> use CGI::Carp('fatalsToBrowser');
> }
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
^ where is the matching curly?
Not closing a block will sometimes give string termination errors.....
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $FORM{$name} = $value;
>
> if ($FORM{'condition'} eq "wave") {
> $type = "0"
> }
>
> if ($FORM{'condition'} eq "freestyle") {
> $type = "3"
> }
>
> if ($FORM{'condition'} eq "freeride") {
> $type = "5"
> }
>
> $FORM{$weight} = ($FORM{$weight} / 10);
>
> $total = ($FORM{weight} + $FORM{$sail} + $type);
> print <<EndHTML;
> print "<html><head><title>Results</title></head>\n";
> print "<body>\n";
> print "<h2>Results</h2>\n";
>
> if ($total<="15") {
> print "waveboard\n"
> };
> if ($total>"15") {
> print "freestyleboard\n"
> };
> if ($total>"17") {
> print "freerideboard\n"
> };
>
> EndHTML
s.
------------------------------
Date: Tue, 07 Jan 2003 10:26:30 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: top-posting (was Re: regexp question)
Message-Id: <3e1aaa3c.285499065@news.cis.dfn.de>
On Tue, 07 Jan 2003 04:43:59 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:
>> Also, I learned that my new reading service provider needs me to
>> write more new text than the amount of old text already present.
>
>Really? Wow! I wouldn't have thought that there are still News-Provider out
>there which enforce a decent posting style. Congratulation that you were
>able to find one!
I disagree that posting more text than old text is
necessary for a properly formatted post.
Consider the following exchange:
-----------------------------------------------------------
Q>How do I recurse through a directory structure,
Q>finding all files with names that end in .htm or
Q>.html that are less than 2 days old?
A>use find from the File::Find module.
A>see 'perldoc File::Find' for details.
-----------------------------------------------------------
I would maintain that the answering post was
properly formatted even though the new text
is shorter than the old.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4356
***************************************