[16550] in Perl-Users-Digest
Perl-Users Digest, Issue: 3962 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 9 11:05:30 2000
Date: Wed, 9 Aug 2000 08:05:16 -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: <965833516-v9-i3962@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 9 Aug 2000 Volume: 9 Number: 3962
Today's topics:
"use strict" error message <jhijas@yahoo.es>
-s switch not recognized in shebang line bluemonkey00@my-deja.com
Re: -s switch not recognized in shebang line <aqumsieh@hyperchip.com>
Re: A fork and Socket problem! <T.Cockle@staffs.ac.uk>
Re: Able to install DBI and DBD::ODBC in Windows 95 pla (NP)
Re: beginner problem (Greg Bacon)
Re: beginner problem (3)
Re: beginner problem (Keith Calvert Ivey)
Re: CGI/Pearl Interfacing w/ DOS Program Question <mjcarman@home.com>
Re: Chess Game (Deep Blue) in Perl? <waltman@netaxs.com>
Re: cleaning shell screen (NP)
Re: correction: sorting problem! output should be (a A <eknaap@lucent.com>
Re: correction: sorting problem! output should be (a A <mauldin@netstorm.net>
Re: files transferred by socket? (Greg Bacon)
Re: Help Regex newbie colincode@my-deja.com
How to source a shell script in perl sankarmukh@my-deja.com
Re: How to source a shell script in perl (Greg Bacon)
Is "close()" really necesary? <jhijas@yahoo.es>
Re: Is "close()" really necesary? (Andreas Kahari)
Re: Is "close()" really necesary? (Greg Bacon)
lamer problem of commiting a perl script (Anno Siegel)
Re: lamer problem of commiting a perl script <uackermann@orga.com>
Re: lamer problem of commiting a perl script <joelnelson@home.net>
Large-File Reformatting Problem (Regexp gurus, et al.) <cjmackie@princeton.edu>
Re: Mailform vnguyen_1999@my-deja.com
Re: Mailform vnguyen_1999@my-deja.com
Ordered set of permutations algorithm <scollick@stsci.edu>
Re: Perl External Program Question (Anno Siegel)
Perl script? <lharwoodNOlhSPAM@lucent.com.invalid>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 09 Aug 2000 16:49:48 +0200
From: Javier Hijas <jhijas@yahoo.es>
Subject: "use strict" error message
Message-Id: <39916F8C.4F6FDFAA@yahoo.es>
Could someone tell me what does it means?
Global symbol "$YP_DIR" requires explicit package name at ./usradm line
16
------------------------------
Date: Wed, 09 Aug 2000 13:45:21 GMT
From: bluemonkey00@my-deja.com
Subject: -s switch not recognized in shebang line
Message-Id: <8mrn9h$lcs$1@nnrp1.deja.com>
Given the following script(test.pl):
#!/usr/bin/perl -s
if($d)
{ print "'D' Switch is defined.\n"; }
I type the following command line:
perl test.pl -d
and I get no output.
However, if I type the following command line:
perl -s test.pl -d
then I get: 'D' Switch is defined.
Why doesn't the -s switch work in the shebang line?
Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 09 Aug 2000 15:04:19 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: -s switch not recognized in shebang line
Message-Id: <7aittacw7f.fsf@merlin.hyperchip.com>
bluemonkey00@my-deja.com writes:
> Given the following script(test.pl):
>
> #!/usr/bin/perl -s
>
> if($d)
> { print "'D' Switch is defined.\n"; }
>
>
> I type the following command line:
> perl test.pl -d
> and I get no output.
>
> However, if I type the following command line:
> perl -s test.pl -d
> then I get: 'D' Switch is defined.
>
> Why doesn't the -s switch work in the shebang line?
Actually, it does, but you should run it like so:
% chmod +x ./test.pl
% ./test.pl -d
I don't know why it works only this way. Perhaps it is a bug?
--Ala
------------------------------
Date: Wed, 09 Aug 2000 14:30:33 +0100
From: Tim Cockle <T.Cockle@staffs.ac.uk>
Subject: Re: A fork and Socket problem!
Message-Id: <39915CF9.4544EA7D@staffs.ac.uk>
Okay here is the offending bit of code and the output.
$server = IO::Socket::INET->new(LocalPort => 3128, Type => SOCK_STREAM, Reuse => 1,
Listen => 10) || die "I can't open a server socket";
$SIG{CHLD} = \&REAPER;
stdout->autoflush(1);
while ($browser = $server->accept()) {
next if $pid = fork;
die "fork: $!" unless defined $pid;
print "child: $pid";
close($server);
&DEAL_WITH_CLIENT($browser);
close($browser);
exit;
} continue {
print "I am a parent: $pid\n";
close($browser);
}
sub REAPER {
1 until (-1 == waitpid (-1, WNOHANG) );
$SIG{CHLD} = \&REAPER;
}
sub DEAL_WITH_CLIENT {
my $lastLoop;
my $httpRequest;
my $httpResponseHearders;
my $responseContentLength;
my $responseContentType;
my $httpResponseEntityBody;
my $extraLength;
my $newContentLength;
my $client = shift;
$proxy = IO::Socket::INET->new("research.soc.staffs.ac.uk:3128") or die "Could
not open socket to reserch proxy: $!\n";
$proxy->autoflush(1);
$client->autoflush(1);
($httpRequest, $lastLoop) = &GET_HTTP_REQUEST($client);
print $proxy $httpRequest or die "\$httpRequest $httpRequest\n I can't write to
the proxy!\n\$! $!\n pid: $pid\n";
($httpResponseHeaders, $responseContentLength, $responseContentType) =
&GET_HTTP_RESPONSE_HEADERS($proxy);
.... some more code!!!
This is what is printed to the screen:
$httpRequest GET http://www.soc.staffs.ac.uk/~cmrtc/ HTTP/1.0
If-Modified-Since: Wed, 04 Nov 1998 19:06:46 GMT; length=430
Proxy-Connection: close
User-Agent: Mozilla/4.7 [en] (WinNT; I)
Pragma: no-cache
Host: www.soc.staffs.ac.uk
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
Accept-Encoding: gzip
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8
I can't write to the proxy!
$! Invalid argument
pid: 0
Thanks,
Tim
Tim Conrow wrote:
> Tim Cockle wrote:
> > Basically my proxy sits between the browser and the real-proxy (that
> > servers my department) parsing HTML.
> >
> > I open a server socket and use the normal while loop to deal with
> > clients:
> > while ($browser = $server->accept()) {
> >
> > If I then fork (the line I use is next if $pid = fork;) and allow to
> > child to open a new socket to the real-proxy I get an error when I try
> > to write.
> > If though I the parent to open the connection to the proxy BEFORE I fork
> > every thing works fine!
> >
> > Can some one tell me why please?!?!?!?!
> > And if/how I can get the child to open the socket to the real proxy?
>
> Please send stripped down code that shows the problem, along with sample inputs
> and outputs. We can't help you with what we can't see.
>
> --
>
> -- Tim Conrow tim@ipac.caltech.edu 626-395-8435
------------------------------
Date: Wed, 09 Aug 2000 13:07:58 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: Able to install DBI and DBD::ODBC in Windows 95 platform Anyone?
Message-Id: <OIck5.454107$MB.6855508@news6.giganews.com>
09 Aug 2000, windy_boy <windy_boyNOwiSPAM@mail.com.invalid> wrote:
:
: I was wondering if anyone has been successfully installed Perl
: DBI and DBD::ODBC in Windows 95 platform. I tried to but it
Well, you could always use the PPM that comes with ActiveState Perl and
install pre-compiled DBI and DBD::ODBC packages. Or is it that you
built your own Perl? If you're using ActiveState Perl (and you don't
have a complete development environment), you should almost certainly
use PPM if a pre-compiled package already exists for your needs.
--
Nate II
------------------------------
Date: Wed, 09 Aug 2000 13:51:43 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: beginner problem
Message-Id: <sp2offcn63a22@corp.supernews.com>
In article <8mrj38$uel$1@netnews.upenn.edu>,
3 <dbaumann@mail1.sas.upenn.edu> wrote:
: use strict;
: my $faq_directory = 'C:\perl\html\lib\pod';
: my @faq_files = ( ##various files like 'perlfaq1.pod'##);
: my $pattern = SARGV[0] or die "no pattern available: $!";
^^^^^^^^
That should be $ARGV[0].
Greg
--
Remember, on Linux, you don't have a choice. You get that fat
bastard every time.
-- Tom Christiansen speaking of bash
------------------------------
Date: 9 Aug 2000 14:31:15 GMT
From: dbaumann@mail2.sas.upenn.edu (3)
Subject: Re: beginner problem
Message-Id: <8mrpvj$5vv$1@netnews.upenn.edu>
3 (dbaumann@mail1.sas.upenn.edu) wrote:
: ##faqgrep.txt##
: use strict;
: my $faq_directory = 'C:\perl\html\lib\pod';
: my @faq_files = ( ##various files like 'perlfaq1.pod'##);
: my $pattern = SARGV[0] or die "no pattern available: $!";
: foreach my $filename (@faqfiles) {
: open (FILE, "$faq_directory\$filename) or die "cant open file: $!";
thanks for the responses...but I jsut quickly typed in this code this
morning (sorry for the errors, you are correct)..my original had no typos or
syntax errors....just the error that that it "could not find perlfaq1.pod in
C:\perl\bin\faqgrep.txt".... I copied this code verbatum from the book.
The problem is that even though I define where my my $faq_directory is
(C:\perl\html\dir\lib\pod) ...the program still tries to find it at "its"
location (C:\perl\bin\faqgrep.txt).
....When I get home tonight I will double check for errors...and try the
// between ($faq_directory//$filename). But I think the problem is
something unrelated to syntax....any other ideas?
thanks,
Don
------------------------------
Date: Wed, 09 Aug 2000 14:12:06 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: beginner problem
Message-Id: <39986629.42679942@news.newsguy.com>
Ulrich Ackermann <uackermann@orga.com> wrote:
>Maybe better: open (FILE, "$faq_directory\\$filename") or die "cant open
>file: $!";
Still better:
open (FILE, "$faq_directory/$filename")
or die "can't open $faq_directory/$filename: $!";
Forward slashes work fine as directory separators on Windows,
and it's a good idea to put the filename in the error message
for situations like the original poster's.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Wed, 09 Aug 2000 08:08:38 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: CGI/Pearl Interfacing w/ DOS Program Question
Message-Id: <399157D6.68ED478A@home.com>
vagabond_nomad@my-deja.com wrote:
>
> I am very, very, very new to CGI / Pearl,
^^^^^
Oysters make those. This is Perl. Saying 'Pearl' here is like stamping
your forehead with NEWBIE in big, red letters. It's fine if you are, but
you don't have to advertise it quite so much.
> My task is to find a way interface a CGI program with a DOS
> program sitting on a UNIX server. Here are the specifics:
>
> From a web browser, a user will start up a DOS program sitting
> on a UNIX server.
Really? DOS programs don't run under Unix. (Not without something line
WINE anyway.) And even if they did, giving Joe Webhead the ability to
run programs via the web is generally a bad idea.
Maybe you need to rethink your problem.
> The DOS program will send output to the user's web browser that
> will be displayed as HTML. The user will then enter some input
> into the web browser, which will then be sent back to the DOS
> program for processing.
[etc., etc. ad naseum]
That's what CGI does, but typically internally, not by going out and
running another application -- it's a potential security issue.. What is
this "DOS program" you're trying to run? Perhaps if you can provide more
details, the folks here can help you.
-mjc
------------------------------
Date: 09 Aug 2000 10:48:42 -0400
From: Walt Mankowski <waltman@netaxs.com>
Subject: Re: Chess Game (Deep Blue) in Perl?
Message-Id: <m3zomm8p85.fsf@netaxs.com>
"Kermit" <as@if.com> writes:
> I understand how to setup the data structure for the table, what I should
> have said was the visual table, ie: the actual chess board interface, I
> don't want to enter "e2f3" or such things.
I'd suggest getting the chess-playing algorithm working before you try
putting a fancy front-end on it.
Walt
------------------------------
Date: Wed, 09 Aug 2000 13:09:27 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: cleaning shell screen
Message-Id: <bKck5.454108$MB.6855508@news6.giganews.com>
On Wed, 09 Aug 2000 14:57:27 +0200, Javier Hijas <jhijas@yahoo.es> wrote:
: How do I clean the shell screen with perl?
See Perl FAQ about "How do I clear the screen?".
--
Nate II
------------------------------
Date: Wed, 09 Aug 2000 16:13:23 +0200
From: Erik van der Knaap <eknaap@lucent.com>
Subject: Re: correction: sorting problem! output should be (a A Aa AA AaA AAa AAA).
Message-Id: <39916703.31463E2D@lucent.com>
Anno Siegel wrote:
>
> Erik van der Knaap <eknaap@lucent.com> wrote in comp.lang.perl.misc:
> >Folks,
> >
> >I want to sort a list in a special way. I want to sort an abbreviation list.
> >@unsorted = qw(AA AAA aA a B C d E dD);
> >
> >And I want the output as:
> >a aA AA AAA B C d dD E
>
> Oh please! If you want help with a problem, invest a little time
> and give us a decent problem specification. Just an example of
> what the output should be for one particular input isn't enough.
Sorry!
>
> sort { lc $a cmp lc $b or $a cmp $b } @unsorted;
yep, I want something like this. (I will use this because the output looks better now).
>
> does what you want, but so does
>
> qw( a aA AA AAA B C d dD E);
I know!
>
> Anno
The problem is I want to sort with a lowercase (higher priority) priority and then Uppercase.
Your example worked of course for my list (stupid example of mine). I have a list of abbreviations and they must be
sorted in a list. My output is still not correct:
example of a correct list I want is: adm AdM ADM AddM ADdM etc.
So first priority lower case, second uppercase.
I think it's tricky to solve.
Regards,
Erik
------------------------------
Date: Wed, 09 Aug 2000 14:58:22 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: correction: sorting problem! output should be (a A Aa AA AaA AAa AAA).
Message-Id: <399170F6.56BC599@netstorm.net>
Erik van der Knaap wrote:
>
> Anno Siegel wrote:
> >
> > Erik van der Knaap <eknaap@lucent.com> wrote in comp.lang.perl.misc:
> > >Folks,
> > >
> > >I want to sort a list in a special way. I want to sort an abbreviation list.
> > >@unsorted = qw(AA AAA aA a B C d E dD);
> > >
> > >And I want the output as:
> > >a aA AA AAA B C d dD E
> >
> > Oh please! If you want help with a problem, invest a little time
> > and give us a decent problem specification. Just an example of
> > what the output should be for one particular input isn't enough.
> Sorry!
>
> >
> > sort { lc $a cmp lc $b or $a cmp $b } @unsorted;
> yep, I want something like this. (I will use this because the output looks better now).
>
> >
> > does what you want,
> >
> > Anno
> The problem is I want to sort with a lowercase (higher priority) priority and then Uppercase.
>
> Your example worked of course for my list (stupid example of mine). I have a list of abbreviations and they must be
> sorted in a list. My output is still not correct:
> example of a correct list I want is: adm AdM ADM AddM ADdM etc.
>
> So first priority lower case, second uppercase.
>
See
perldoc -f sort
I believe that Anno's excellent example gives you what you want unless
you have failed to fully specify what you want, in which case no help is
possible. Her sort says, essentially, ascending order without regard to
case, or if they're equal, descending order. So adm comes before aDm or
ADM.
-- Jim
------------------------------
Date: Wed, 09 Aug 2000 14:00:27 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: files transferred by socket?
Message-Id: <sp2ovrtu63a74@corp.supernews.com>
In article <8mrbk4$7sn@netnews.hinet.net>,
<u8526505@ms27.hinet.net> wrote:
: I tried to send files from socket by this way
:
: server:
: open(FILE,$file) or die "error";
: binmode(FILE);
: while(<FILE>){
: print $sock $_;
: }
: close FILE;
:
: client:
: open(NEWFILE,">newfile");
: while(defined ($_=<$sock>)){
: print NEWFILE $_;
: }
: close (NEWFILE);
The client while loop is more simply written as
while (<$sock>) {
print NEWFILE $_;
}
: the data that client receive is always larger than the original one.why?
: I tried both text and binary file and the result is the same.
: If I comment the binmode then it works for text file but not binary.
It appears that you're running the client on a Windows box. The reason
that the client outputs a larger file is that text mode files on Windows
translate LF to CR LF on output.
: Is there a general way for both types of files?
The solution is to binmode() the output handle (on the client side) too.
: The problem is encountered on windows platform and O.K. for linux.
: does this problem result from the platform issue?
Yes. Unix systems don't distinguish between text and binary streams
and don't perform end-of-line translations.
Greg
--
Fry: I'm just not a one-woman guy.
Leela: Don't worry; you'll be back down to zero soon enough.
------------------------------
Date: Wed, 09 Aug 2000 14:15:28 GMT
From: colincode@my-deja.com
Subject: Re: Help Regex newbie
Message-Id: <8mrp1t$mi2$1@nnrp1.deja.com>
Thanks, I appreciate everyones help. This makes more sense than the
book did.
Colin Faulkingham
> > or, without substr():
> >
> > my $string = 'Boeing';
> >
> > some_function if $string =~ /^[a-c]{1}.*/i
>
> Yer confusin' me wit all dose squiggly things. How about
>
> ... if $string =~ /^[a-c]/i
>
> instead?
>
> --
> Russ Jones - HP OpenView IT/Operatons support
> Raytheon Aircraft Company, Wichita KS
> russ_jones@rac.ray.com 316-676-0747
>
> Quae narravi, nullo modo negabo. - Catullus
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 09 Aug 2000 13:53:09 GMT
From: sankarmukh@my-deja.com
Subject: How to source a shell script in perl
Message-Id: <8mrno4$lnh$1@nnrp1.deja.com>
I have a script which works in all ksh environment. For varous reasons,
perl Ftp also has to work for me. I am psting an abbreviated test
version. I am sure that I don't know how to pass the variables from
cntrlFile to perl. Here is the Perl part:
*************************************************************
#!/usr/local/bin/perl -w
use Net::FTP;
#$user="prod";
#$hspw="smuk";
`. /u/ctssmuk/sankar/cntrlFile`;
#I want the cntrlFile variable to be exportd to $user,#hspw.
$ftp = Net::FTP-> new ("hbcmg001");
$ftp->login ("$user","$hspw") || die "Can't login";
print "Current dir is ", $ftp->pwd, "\n"; $ftp->quit;
************************************************************
The cntrlFile is:
hbcmgd003:/u/ctssmuk> more cntrlFile
#!/bin/ksh
set -- `crypt ftp_00 <passfile.enc`
user=$1
hspw=$2
fppw=$3
jcpw=$4
Any help is appreciated. Regards.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 09 Aug 2000 14:11:09 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: How to source a shell script in perl
Message-Id: <sp2pjt8q63a183@corp.supernews.com>
In article <8mrno4$lnh$1@nnrp1.deja.com>,
<sankarmukh@my-deja.com> wrote:
: I have a script which works in all ksh environment. For varous reasons,
: perl Ftp also has to work for me. I am psting an abbreviated test
: version. I am sure that I don't know how to pass the variables from
: cntrlFile to perl. Here is the Perl part:
:
: #!/usr/local/bin/perl -w
: use Net::FTP;
:
:
: #$user="prod";
: #$hspw="smuk";
: `. /u/ctssmuk/sankar/cntrlFile`;
:
: #I want the cntrlFile variable to be exportd to $user,#hspw.
:
: $ftp = Net::FTP-> new ("hbcmg001");
: $ftp->login ("$user","$hspw") || die "Can't login";
Don't do that. You're creating new scalars where the originals would
do just fine. (This bad habit can burn you in some cases.) It's better
to say
$ftp->login ($user, $hspw) || die "Can't login";
: print "Current dir is ", $ftp->pwd, "\n"; $ftp->quit;
:
: The cntrlFile is:
:
: hbcmgd003:/u/ctssmuk> more cntrlFile
: #!/bin/ksh
: set -- `crypt ftp_00 <passfile.enc`
: user=$1
: hspw=$2
: fppw=$3
: jcpw=$4
Export user, hspw, fppw, and jcpw. Then call your Perl program from
the bottom of your Korn shell script.
Greg
--
guru, n.:
A person in T-shirt and sandals who took an elevator ride with
a senior vice-president and is ultimately responsible for the
phone call you are about to receive from your boss.
------------------------------
Date: Wed, 09 Aug 2000 15:57:23 +0200
From: Javier Hijas <jhijas@yahoo.es>
Subject: Is "close()" really necesary?
Message-Id: <39916343.152B046A@yahoo.es>
"Programming Perl" recommends no to use it as a file will be closed when
you reopen them, so, when should I use this function?
------------------------------
Date: 9 Aug 2000 16:11:37 +0100
From: andkaha@hello.to.REMOVE (Andreas Kahari)
Subject: Re: Is "close()" really necesary?
Message-Id: <39916699@merganser.its.uu.se>
In article <39916343.152B046A@yahoo.es>, Javier Hijas <jhijas@yahoo.es> wrote:
>"Programming Perl" recommends no to use it as a file will be closed when
>you reopen them, so, when should I use this function?
The documentation states that you don't have to close() the handle if
you IMMEDIATELY are going to do another open() on it.
A close() will flush the buffers associated with the handle. If you
want to be sure that everything gets written to your file, then you
should explicitly close() the filehandle. Otherwise things may get
lost if the program is interrupted before it ends. This goes for C and
C++ as well.
/A
--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# ...brought to you from Uppsala, Sweden.
# All junk e-mail is reported to the appropriate authorities.
# Criticism, cynicism and irony available free of charge.
------------------------------
Date: Wed, 09 Aug 2000 14:17:41 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Is "close()" really necesary?
Message-Id: <sp2q05pl63a17@corp.supernews.com>
In article <39916343.152B046A@yahoo.es>,
Javier Hijas <jhijas@yahoo.es> wrote:
: "Programming Perl" recommends no to use it as a file will be closed when
: you reopen them, so, when should I use this function?
One side-effect of close() is that it resets $. for that handle. If
the handle came from a piped open, e.g.,
open ECHO, "echo foo |" or die "$0: can't start echo: $!";
open GREP, "| grep foo" or die "$0: can't start grep: $!";
then the close() waits for the process on the other end of the pipe.
This is a good thing. :-)
See the documentation on close in the perlfunc manpage.
Greg
--
Fenster: Treat me like a criminal, I'll end up a criminal.
Hockney: You are a criminal.
Fenster: Why you gotta go and do that? I'm trying to make a point.
------------------------------
Date: 9 Aug 2000 13:16:01 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: lamer problem of commiting a perl script
Message-Id: <8mrlih$3d2$1@lublin.zrz.tu-berlin.de>
HD <elbereth*nospam*@gmx.de> wrote in comp.lang.perl.misc:
>I am starting in perl a few days ago
>
>#!/usr/bin/perl
>
>
>if($ENV{'REQUEST_METHOD'} eq 'GET')
> {
> $Daten = $ENV{'QUERY_STRING'}
> }
>else
> {
> read(STDIN, $Daten, $ENV{'CONTENT_LENGTH'});
> }
>
>@Formularfelder = split(/&/, $Daten);
>foreach $Feld (@Formularfelder)
> {
> ($name, $value) = split(/=/, $Feld);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ s/<!--(.|\n)*-->//g;
> $Formular[$i] = $name;
> $i = $i + 1;
> $Formular[$i] = $value;
> $i = $i + 1;
> }
>
>print "Content-type: text/html\n\n";
>print "<html>\n";
>print "<head>\n";
>print "<title>Danke!</title>\n";
>print "</head>\n";
>print "<body bgcolor=#FFFFFF text=#000000 link=#009900 vlink=006600
>alink=#0000FF>\n";
>print "<h1>Danke</h1>\n";
>print "Wir freuen uns, daß Sie unser Formular ausgefüllt \n";
>print "haben. Hier zur Kontrolle Ihre Angaben:<p>\n";
>
>for($i=0;$i<=$max;$i=$i+2)
>{
> print "<b>$Formular[$i]:</b> $Formular[$i+1]<br>\n";
>}
>print "<p><hr noshade size=1><p>";
>print "<i>Ihr Name, <a href=\"mailto:IhrName\@Provider.xx\">IhrName\@Provider.xx</a></i>";
>print "</body>\n";
>print "</html>\n";
>
>
>I checked the syntax of the script and everything went right. I uploaded this script called comments.pl (gave rights of 775 to it) to a linux redhat-server, checked the existens of #!/usr/bin/perl.
>But after running the script I got only the script, what did I wrong? Do I have to compile it like a java.applet or so, please help I have to finish the project on friday this week!
This isn't a Perl problem. Ask the admin of your server how to install
CGIs on that machine. This depends heavily on the configuration of the
web server.
Oh, and please keep your line length below 72 characters or so in Usenet
postings.
Anno
------------------------------
Date: Wed, 09 Aug 2000 15:33:22 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: lamer problem of commiting a perl script
Message-Id: <39915DA2.6D035D82@orga.com>
HD wrote:
>
> I am starting in perl a few days ago
>
> #!/usr/bin/perl
You should *always* use a shebang line like
#!/usr/bin/perl -w
^^^
This might give you already all that you might want to know. (undefined
variable $max in this case).
It is also strongly recommended to use the 'use strict;' pragma which
helps you avoiding global variables e.g.
HTH,
Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: Wed, 09 Aug 2000 14:23:48 GMT
From: Joel Nelson <joelnelson@home.net>
Subject: Re: lamer problem of commiting a perl script
Message-Id: <3991694E.98AA8C15@home.net>
HD wrote:
> I am starting in perl a few days ago
>
> I checked the syntax of the script and everything went right. I uploaded this script called comments.pl (gave rights of 775 to it) to a linux redhat-server, checked the existens of #!/usr/bin/perl.
> But after running the script I got only the script, what did I wrong? Do I have to compile it like a java.applet or so, please help I have to finish the project on friday this week!
Sounds like the web server may not be configured to recognize .pl files. Try .cgi instead or contact web admin to resolve. Not a perl question really.
Joel
------------------------------
Date: Wed, 9 Aug 2000 10:33:47 -0400
From: "Christopher J. Mackie" <cjmackie@princeton.edu>
Subject: Large-File Reformatting Problem (Regexp gurus, et al.)
Message-Id: <8mrq5v$1aa$1@cnn.Princeton.EDU>
I have a very large (multi-Gb) file -- far too big to read into memory in
one chunk -- that has an unknown number of internal formatting errors of a
specific type, and I need some advice about how to fix it.
The proper format is a number of lines of text (1 to approx. 280k lines
ending in single newlines) separated by exactly one blank line (i.e.,
'\n\n'). The errors consist only of excess whitespace between the texts (an
unknown and presumably variable number of extra newlines, plus, perhaps,
some whitespace interspersed-with and/or bracketing the newlines). I have
to remove the excess whitespace and newlines, leaving only '\n\n', and
without removing any of the legitimate, line-ending newlines in the interior
of the texts.
I've got a number of these files, and will have to do this repeatedly, so I
need a routine that takes as little CPU time as possible. I had thought
about setting $/ to "", to read in the well-formatted texts separately, then
using regexps to eliminate whitespace at the beginning and in the middle of
each text:
$/="";
while (<>) {
s/^[\n\s]+//s; # strip beginning whitespace, incl. newlines
s/[\n\s]+$//s; # strip ending whitespace, incl. newlines
1 while (s/\n\s+\n/\n\n/g); # remove whitespace in any interior blank
lines ('1 while' to ensure overlapping problems get fixed on additional
passes)
s/\n\n\n+/\n\n/g; # more than two interior newlines becomes two
newlines
s/\n*$/\n\n/s; # replace final newlines
next unless /\w/; # skip outputting line if I've retrieved a (by-error)
empty document (well-formatted texts contain no punctuation or other
non-alpha characters, so \w is fine as a test)
print;
}
Some questions for the gurus:
(1) will this do what I want? (will it find all instances the first time, or
will it miss something?)
(2) Is there a way to tweak this? (e.g., is there something faster and as
certain as '1 while'? Are there other optimizations I can use?)
(3) Is there some other approach, entirely different, that beats any
tweaking of this approach?
Many tia, --Chris Mackie
======================
Politics Department
Princeton University
cjmackie@princeton.edu
------------------------------
Date: Wed, 09 Aug 2000 13:10:13 GMT
From: vnguyen_1999@my-deja.com
Subject: Re: Mailform
Message-Id: <8mrl7j$k62$1@nnrp1.deja.com>
No codes, no clue to help. Send us some actual codes so that we know
what's going on.
In article <8mqst5$1lv4$1@beast.euro.net>,
"Ronald Kas" <unartic@cistron.nl> wrote:
> Hi there!
>
> I'm completely new at perl, and though I'm formiliar with html, asp,
> javascript , I want to learn more about perl. I'm trying to write a
script
> that sends a form by email, but I receive the following error from my
> logfile:
>
> 'Premature end of script headers'
>
> That is this causing and how do I fix it?
>
> Question 2:
> Does anybody now some good sites on which I can learn perl?
>
> Thanx!
>
> Ronald
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 09 Aug 2000 13:13:10 GMT
From: vnguyen_1999@my-deja.com
Subject: Re: Mailform
Message-Id: <8mrld3$k6t$1@nnrp1.deja.com>
No codes, no clue to help. Send us some actual codes so that we know
what's going on.
In article <8mqst5$1lv4$1@beast.euro.net>,
"Ronald Kas" <unartic@cistron.nl> wrote:
> Hi there!
>
> I'm completely new at perl, and though I'm formiliar with html, asp,
> javascript , I want to learn more about perl. I'm trying to write a
script
> that sends a form by email, but I receive the following error from my
> logfile:
>
> 'Premature end of script headers'
>
> That is this causing and how do I fix it?
>
> Question 2:
> Does anybody now some good sites on which I can learn perl?
>
> Thanx!
>
> Ronald
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 9 Aug 2000 10:19:59 -0400
From: "Keith Scollick" <scollick@stsci.edu>
Subject: Ordered set of permutations algorithm
Message-Id: <8mrpag$db4$1@tomm.stsci.edu>
Hi all,
I have a set of elements that can range anywhere from one to approximately
ten elements. What I want to do is create a set of all ordered combinations
(i.e. the elements on the left stay to the left of any and all elements to
the right)
not limited to just returning the combinations with the same number of
elements
as the original list (i.e. for a three element list, I want each combination
of
two as well).
For example, given a list (1, 2, 3, 4, 5). I want to return an array
containing
(each element is separated by a comma):
1, 2, 3, 4, 5, 1 2, 1 3, 1 4, 1 5, 2 3, 2 4, 2 5, 3 4, 3 5,
1 2 3, 1 2 4, 1 2 5, 1 3 4, 1 3 5, 2 3 4, 2 3 5, 3 4 5,
1 2 3 4, 1 2 3 5, 1 2 4 5, 1 3 4 5, 2 3 4 5, 1 2 3 4 5
Is there a good way of doing this? I'm getting bogged down in the
recursive nature of all this.
Any help (or pointing in the right direction) is greatly appreciated.
--Keith Scollick
scollick@stsci.edu
------------------------------
Date: 9 Aug 2000 13:07:23 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl External Program Question
Message-Id: <8mrl2b$3b2$1@lublin.zrz.tu-berlin.de>
<vagabond_nomad@my-deja.com> wrote in comp.lang.perl.misc:
>I am very, very, very new to CGI / Pearl, so I apologize in advance for
>my vast ignorance on this subject. My task is to find a way interface a
>CGI program with a DOS program sitting on a UNIX server. Here are the
>specifics:
[snip]
Huh? You want to run a DOS program on a Unix machine? Short of
installing a DOS emulator, there's no way this is going to work.
Anno
------------------------------
Date: Wed, 09 Aug 2000 07:03:33 -0700
From: Lovena Harwood <lharwoodNOlhSPAM@lucent.com.invalid>
Subject: Perl script?
Message-Id: <0aa5d029.0f452258@usw-ex0104-026.remarq.com>
There is a wonderful site I just found today called "Aloha,
write you message in the Hawaiian sand". There are fields for
entering text and the resulting image with your message is
emailed to a recipient of your choice.
I am trying to locate a script that does this (I'd be using a
different background and have it hosted) and would like to know
if anyone may know of a source.
Thanks!
Lovena
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
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 3962
**************************************