[18942] in Perl-Users-Digest
Perl-Users Digest, Issue: 1137 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 14 18:10:30 2001
Date: Thu, 14 Jun 2001 15:10:12 -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: <992556612-v10-i1137@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 14 Jun 2001 Volume: 10 Number: 1137
Today's topics:
Re: Premature end of srcipt headers? <mrdeza@phys.ucalgary.ca>
Re: Premature end of srcipt headers? <bart.lateur@skynet.be>
Re: Premature end of srcipt headers? <mrdeza@phys.ucalgary.ca>
Re: Premature end of srcipt headers? <godzilla@stomp.stomp.tokyo>
Re: Removing ^M characters <EvR@compuserve.com>
setting @INC at perl compile time <elijah@workspot.net>
Re: straycat in this regex <keesh@users.sf.net>
Re: Validating postcodes <wayne@wmcomputing.com>
When Not To Mix select & read/print/<> (yes i RTFM) (LMC)
Re: Which C compiler to use for modules? <hillr@ugs.com>
Why does my a: grind when I copy a file in perl? <temp133@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 Jun 2001 13:09:29 -0600
From: Jason Mrdeza <mrdeza@phys.ucalgary.ca>
Subject: Re: Premature end of srcipt headers?
Message-Id: <3B290BE8.BEC1B894@phys.ucalgary.ca>
First of all thanks to everyone that replied...
-I actually had the right spacing in my header in the code. I just posted
it on the board wrong, so that wasn't the cause of the error.
-I tried to print out the errors as Mr.Lateur suggested, but didn't even
receive and error message.
Here is the code, and sorry for not posting it at first...
____________________________________________________ _ _ _ _
#!/usr/local/bin/perl -w
use English;
use diagnostics;
use strict;
#BEGIN
# {
# open STDERR, ">&STDOUT";
# print "Content-type: text/html\n\n<PRE>";
# }
$| = 1; #this clears out the stdout
my (%inputo); #this declares the hash where the input will go
my (@files);
my ($rfile);
my ($year);
my ($month);
my ($day);
my (@lines);
my ($gillam600);
my ($gillam700);
my ($gillam800);
my ($eureka600);
my ($eureka700);
my ($eureka800);
getInputo (\%insub getInputo
{
my ($hashRef) = shift; #initialize the variable to hold the hash
reference
my ($buffer) = ""; #initialize the buffer to hold info
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); #reads in the form
info
foreach (split(/&/, $buffer)) #goes through the whole buffer
where the input is stored
{
my ($key, $value) = split(/=/, $_); #splits up the input
into the date and value
$key = decode($key); #sets the key and value to the
decoded values
$value = decode($value);
$hashRef->{$key} = $value; #sets the key and value in the
hash table
}
}
sub decode
{
$_ = shift; #the decode function which gets rid of all the stars
which represent spaces
tr/+/ /;
s/%(..)/pack('c', hex($1))/eg; #convert any symbols out of hex
back to symbols
return($_);
}
sub mainer
{
opendir (DIR, "~/datas/"); #open the directory where all
the text files are
@files = sort(grep (/txt$/, readdir(DIR))); #finds all
the text files in the directory
closedir (DIR);
foreach (@files)
{
$rfile = grep (/$year-$month-$day/, $_); #find
the file whos title matches the date
}
if ( ! $rfile )
{
return ($eureka600, $eureka700,
$eureka800, $gillam600, $gillam700, $gillam800);
}
open (FILE, $rfile);
@lines= <FILE>; #read in the desired file
close FILE;
foreach (@lines)
{
$eureka600= grep(/eureka600/, $_); #these loops
search through the
#file to see if
the given strings are
#present
}
foreach (@lines)
{
$eureka700 = grep(/eureka700/, $_);
}
foreach (@lines)
{
$eureka800= grep(/eureka800/, $_);
}
foreach (@lines)
{
$gillam600= grep(/gillam600/, $_);
}
foreach (@lines)
{
$gillam700= grep(/gillam700/, $_);
}
foreach (@lines)
{
$gillam800= grep(/gillam800/, $_);
}
return ($eureka600, $eureka700, $eureka800, $gillam600,
$gillam700, $gillam800);
#returns the variables back to the javascript
program..
print "Location: ~/public_html/data1.html\n\n"; #the document we
want the info passed to
print "Window-target: sites\n\n"; #the frame where we want the
html doc to appear
}
_______________________________________________ _ _ _
------------------------------
Date: Thu, 14 Jun 2001 20:12:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Premature end of srcipt headers?
Message-Id: <pm6iitobrj4a6gv36eqel2tplo2sq07knk@4ax.com>
Jason Mrdeza wrote:
>getInputo (\%insub getInputo
>
> {
> my ($hashRef) = shift; #initialize the variable to hold the hash
>reference
...
This is not valid Perl.
--
Bart.
------------------------------
Date: Thu, 14 Jun 2001 14:31:09 -0600
From: Jason Mrdeza <mrdeza@phys.ucalgary.ca>
Subject: Re: Premature end of srcipt headers?
Message-Id: <3B291F0D.9FCFD9CE@phys.ucalgary.ca>
Bart Lateur wrote:
> Jason Mrdeza wrote:
>
> >getInputo (\%insub getInputo
> >
> > {
> > my ($hashRef) = shift; #initialize the variable to hold the hash
> >reference
> ...
>
> This is not valid Perl.
>
> --
> Bart.
Terribly sorry, but I made an errror in my copying of my code to the post...
that section looks like this...
Thanks for the assistance...
___________ __ __ _
getInputo (\%inputo); # function calls....
mainer ();
sub getInputo # beggining of the getInputo function....
{
my ($hashRef) = shift; #initialize the variable to hold the hash
reference
my ($buffer) = ""; #initialize the buffer to hold info
------------------------------
Date: Thu, 14 Jun 2001 14:21:41 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Premature end of srcipt headers?
Message-Id: <3B292AE5.F325EBC2@stomp.stomp.tokyo>
Jason Mrdeza wrote:
> Bart Lateur wrote:
> > Jason Mrdeza wrote:
(snipped)
> > >getInputo (\%insub getInputo
> > > {
> > > my ($hashRef) = shift; #initialize the variable to hold the hash
> > >reference
> > ...
> > This is not valid Perl.
Quite fatal at that.
> Terribly sorry, but I made an errror in my copying of my code to the post...
> that section looks like this...
"...looks like this..."
I am estimating at least 3,812,473 different people posting
here have typed those exact words, 830,172,376 times.
Such a coincidence.
> getInputo (\%inputo); # function calls....
> mainer ();
> sub getInputo # beggining of the getInputo function....
[Thu Jun 14 14:11:30 2001] [error] [client 127.0.0.1]
Premature end of script headers: c:/apache/users//test/test1.pl
Add this at the beginning of your script:
print "Content-type: text/plain\n\n Done\n\n";
Once you have done this, start working on discovering
why your mainer sub-routine doesn't work. When it does
work, your script will send a success message by
crashing and burning. This would be a good time to
remove what you added above.
Godzilla!
------------------------------
Date: Thu, 14 Jun 2001 12:42:39 -0600
From: "Richard A. Evans" <EvR@compuserve.com>
Subject: Re: Removing ^M characters
Message-Id: <9gb20d$gfq$1@sshuraab-i-1.production.compuserve.com>
Since DOS/Windows file typically (always?) use \r\n at the end of the line,
I do not replace the \r with \n, as this results in a double linefeed, \n\n;
I simply replace \r with nothing, using
s/\r//g;
Regards,
Rick Evans
------------------------------
Date: 14 Jun 2001 20:21:58 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: setting @INC at perl compile time
Message-Id: <eli$0106141555@qz.little-neck.ny.us>
So I've playing around with perl 5.6.1 trying to customize the
build to minimize my use of -Ilibdir and $ENV{PERL5LIB}.
I don't see an easy way to specify the exact list of directories
to search. And although I specified a binary compatible build,
and told configure to use my 5.005 and 5.6.1 lib directories,
I didn't see those get added automatically.
I've ended up pushing a bunch of stuff into the config.sh
"otherlibdirs" variable, but is that the right way? And how
much of a bad thing is it to have a directory appear multiple
times in @INC? I've still got my PERL5LIB environment variable
for now...
Elijah
------
thought less of the @INC building would be done at runtime
------------------------------
Date: Thu, 14 Jun 2001 18:57:43 GMT
From: Ciaran McCreesh <keesh@users.sf.net>
Subject: Re: straycat in this regex
Message-Id: <HO7W6.12214$J25.1722966@news1.cableinet.net>
On Thursday 07 June 2001 9:46 pm, tuxy declared:
> I want to remove all instances of \ncat\n from a scalar, thus
>
> dog
> cat
> cat
> man
>
> becomes:
>
> dog
> man
>
> So i figure something line s/\ncat\n/\n/g would do the trick right?
No, because you're getting rid of the \n on both sides of the first cat,
and the second one doesn't pick up the next cat because the newline you
stuck in doesn't count. How about s/(?<=\n)cat(?=\n)//g ? That's any cat
which doesn't have a newline before or after it, will also match at the
start and end even if there's no newline.
--
Ciaran McCreesh
mail: keesh at users dot sf dot net
web: http://www.opensourcepan.com
------------------------------
Date: Thu, 14 Jun 2001 22:41:58 +0100
From: "Wayne Marrison" <wayne@wmcomputing.com>
Subject: Re: Validating postcodes
Message-Id: <DgaW6.5390$A45.665012@news2-win.server.ntlworld.com>
Thanks guys.. thats wonderful.. I did sort a solution out.. but it was
very... primitive in comparison..
Thanks again.
Wayne
"Wayne Marrison" <wayne.marrison@consignia.com> wrote in message
news:992531792.602668@igateway.postoffice.co.uk...
> Hi People....
>
> I have a slight problem .....
>
> I need to validate postcodes given to my program to ensure that they
> correspond to the RoyalMail standard (UK).
>
> I have the patterns required, i.e. "AN NAA","ANN NAA","AAN NAA","AANN
> NAA","ANA NAA","AANA NAA","AAA NAA" (with or without the space) and need
to
> ensure that the code passed to my program conforms to one of the above
> (A=Alpha, N=Numeric).
>
> I have checked the FAQ's but cannot find anything that does the job. I
have
> also checked CPAN for a relevant module,but again, without much success.
>
> As I'm no expert on REGEX, I was wondering if anyone knew the answer to
this
> little problem.
>
> Thanks in advance
>
> Wayne
>
>
>
------------------------------
Date: Thu, 14 Jun 2001 14:21:02 -0400
From: "Antoine Beaupre (LMC)" <Antoine.Beaupre@lmc.ericsson.se>
Subject: When Not To Mix select & read/print/<> (yes i RTFM)
Message-Id: <3B29008E.5020808@lmc.ericsson.se>
Hi
This somehow is a followup on my previous "Multiplexing stdin and stderr
to screen and logfile".
I have been able to use the IO::Select API to do what I need and started
converting a few print and <> around the code to fix the issue, however,
I'm wondering....
The select() documentation from perlfunc(1) says:
"
WARNING: Do not attempt to mix buffered I/O (like
read() or <FH>) with select(). You have to use
sysread() instead.
"
Alright, that's what I did, but do I need to change *all the occurences*
or just the ones regarding the same streams? E.g. I read a config file
in the process. Can I still read it via <>?
The perldoc -f select somehow mentions something different (!!):
"
B<WARNING>: One should not attempt to mix buffered I/O (like C<read()>
or E<lt>FHE<gt>) with C<select()>, except as permitted by POSIX, and
even then only on POSIX systems. You have to use C<sysread()> instead.
"
(great, along with pod formatting... :)
Do I have to read the whole POSIX spec to know when it's permitted??? :)
And would anyone have a easy reference to that spec, by any chance?
Thank you very much.
A.
--
La sémantique est la gravité de l'abstraction.
------------------------------
Date: Thu, 14 Jun 2001 11:28:20 -0700
From: Ron Hill <hillr@ugs.com>
Subject: Re: Which C compiler to use for modules?
Message-Id: <3B290244.DD8DD8FE@ugs.com>
David Coppit wrote
[snipped]:
> However, I tend to think that if you ask the module
> author nicely, they'll compile it and release a ppm package.
I must say that I do not agree with this. If you are running WNT and need
a module that does not have a ppm dist. you are on your own. Case in
point, Crypt::SSLeay
Currently there exists a ppm distribution for this module it is at rev
0.17. I have downloaded and installed it and it works. Great! the problem
is I need proxy support and that did not happen till 0.19 and above. So
off to CPAN I go. I download the latest version and run the configure and
nmake and nmake test and everything seems to work. then I install it using
nmake install.
then I try the lwp-ssl-test script that came with the distribution and
receive application error perl.exe referenced memory could not be read. :(
Next I e-mailed the author asking if he can make a ppm distro of the
module and here was his reply:
Ask ActiveState to compile/release it for you. I only get
it to compile on an old NT perl 5.004_04 for personal use.
So you see, it is not that easy to compile and install c compiled modules
on WNT and very little support is given to do so.
Ron
------------------------------
Date: Thu, 14 Jun 2001 11:56:43 -0700
From: "Arvin Portlock" <temp133@hotmail.com>
Subject: Why does my a: grind when I copy a file in perl?
Message-Id: <9gb1di$2c4l$1@agate.berkeley.edu>
I'm guessing this isn't a perl-specific question, or at least the
solution won't be perl-specific.
Whenever I do file copy in perl, my a: drive starts to grind for
a couple of seconds, even though I'm not copying anything to
or from a: (I'm using the latest ActiveState win32 perl on
Windows 95). The file copy always works fine but the grinding
a: drive is annoying. I'm using backticks like so:
$from = "c:\\files\\file1.txt";
$to = "c:\\morefiles\\file2.txt";
`copy $from $to`;
*grind* *grind* *grind*
Anybody have any ideas why my computer does this and how
I can stop it? I prefer not to use a module for something so simple.
Regards
------------------------------
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 1137
***************************************