[15587] in Perl-Users-Digest
Perl-Users Digest, Issue: 3000 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 10 06:05:35 2000
Date: Wed, 10 May 2000 03:05: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: <957953111-v9-i3000@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 10 May 2000 Volume: 9 Number: 3000
Today's topics:
Re: #How to parse and strip perl comments? <gellyfish@gellyfish.com>
Re: after the whatever.cgi? question? <gellyfish@gellyfish.com>
Re: Apache perlmod updating - How? geoff_gunner@my-deja.com
Re: Can a informix database manipulated by perl program <jeff.beard@xor.com>
Re: dns lookup on choosen name server? <gellyfish@gellyfish.com>
Re: Flame my code <dave@dave.org.uk>
Re: Gotta be in the FAQ...but it doesn't seem to be... <jeff.beard@xor.com>
Re: Gotta be in the FAQ...but it doesn't seem to be... <jeff@vpservices.com>
Re: Gotta be in the FAQ...but it doesn't seem to be... <lr@hpl.hp.com>
Re: Help Needed - Perl Matching Operator <anmcguire@ce.mediaone.net>
Re: Help Needed - Perl Matching Operator <shell@hkscript.com>
Help!! Perl and dll <wstsoi@hongkong.com>
Re: How can I call a perl script from html-page <saddek@arch.chalmers.se>
Re: how do I open it (Abigail)
Re: How many times is it found? (Rafael Garcia-Suarez)
Re: How many times is it found? (Andrew Johnson)
How to create child process under windows ? sodiska@my-deja.com
Re: Install Help needed Mail::Sender.pm (David Efflandt)
Re: Iterating an array question? <billy@arnis-bsl.com>
newbie alert: generating html output without using cgi. <torduange@geocities.com>
Re: newbie alert: generating html output without using <jeff@vpservices.com>
Re: Newbie brain fade (Bart Lateur)
Re: Newbie brain fade (Bart Lateur)
Re: Perl DBI <jeff.beard@xor.com>
Re: Perl DBI <baughj@rpi.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 May 2000 21:59:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: #How to parse and strip perl comments?
Message-Id: <8f9u8f$msp$1@orpheus.gellyfish.com>
On Tue, 09 May 2000 07:59:48 +1000 Peter Hill wrote:
> Abigail wrote:
>>
>> In article <390E2796.3D1E@modulus.com.au>, Peter Hill wrote:
>> >Tom Phoenix wrote:
>> >[snip]
>> >> Oh, you want a program to do it. That smells as if you want to obfuscate
>> >> your code.
>> >
>> >No. My code is sufficiently obscure as it is, and needs no help in that
>> >direction - I'm just production prepping some heavily (indeed
>> >excessively) commented code.
>>
>> That begs the question, why can't production code have comments?
>>
>> Abigail
> No reason, indeed. But nor does it beg the question. I want to strip the
> existing comments which are excessive,
Yeah but I have programs with comments like :
When I could see again the driver was climbing into the
caleche, and the wolves disappeared. This was all so strange
and uncanny that a dreadful fear came upon me, and I was
afraid to speak or move. The time seemed interminable as we
swept on our way, now in almost complete darkness, for the
rolling clouds obscured the moon.
And I would be very upset if that was removed as it says more about the
code it is from than any 'appropriate' comments.
/J\
--
Safety? But sir! If truth be known, I actually caused more accidents
around here than any other employee, including a few doozies no one
every found out about.
--
fortune oscar homer
------------------------------
Date: 9 May 2000 22:38:54 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: after the whatever.cgi? question?
Message-Id: <8fa0he$u40$1@orpheus.gellyfish.com>
On Tue, 9 May 2000 10:54:35 -0400 Erick Jensen wrote:
> "Jeff Zucker" <jeff@vpservices.com> wrote in message
> news:3918243D.99821873@vpservices.com...
>> Erick Jensen wrote:
>> >
>> > The part after the ? is called the query string.
>>
>> That's true.
>>
>> > The following code should work:
>> >
>> > ## Parse the query string
>> > $lsQueryString = $ENV{'QUERY_STRING'};
>>
>> Change "should work" to "may work under limited circumstances and is
>> bound to fail in other circumstances and to present security risks in
>> other circumstances". This do-it-yourself approach to parsing query
>> strings has been discussed on this newsgroup hundreds of times. Unless
>> you know what you are doing (which from this code it is evident you do
>> not), you should use CGI.pm.
>>
>
> Sorry Mr. Perl Guru. I've used that bit of code for over 3 years now and
> have never had a problem. Maybe you should post your replies to
> alt.unwanted.commentary.
>
I would suggest that you post to alt.dev.null if *you* have any further
opinions you would care to express on this matter.
Congratulations you are the hundredth individual entry in my killfile.
/J\
--
Uh, Lisa, the whole reason we have elected officials is so we don't have
to think all the time. Just like that rainforest scare a few years back:
our officials saw there was a problem and they fixed it, didn't they?
--
fortune oscar homer
------------------------------
Date: Wed, 10 May 2000 08:45:50 GMT
From: geoff_gunner@my-deja.com
Subject: Re: Apache perlmod updating - How?
Message-Id: <8fb7jr$ecp$1@nnrp1.deja.com>
> What is the difference between the perlmod and Perl?
> And, any ideas how I can update my perlmod module
> [ to use DBD::Sybase ]
When you build mod_perl into Apache, you start the process off with
a 'perl Makefile.PL'. That uses the configuration details that were set
when you built perl, like what @INC should evaluate to. It's best to
think of mod_perl as simply a way to link into your currently installed
perl.
So: if you want modules available for mod_perl, you install against
your real perl.
You say you've done this already, so here's what you should do:
* Check that mod_perl is running the version of perl that you expect.
* Try writing a little CGI script that lists @INC - is your DBD::Sybase
installed here?
* Does DBD::Sybase actually work? Your CGI scripts should be runnable
from the command line unless you've encoded Apache-specific stuff, so
try running them from the command line.
You may find you need to run Apache with the SYBASE environment
variable is set up (I use 'SYBASE=... bin/apachectl start', using a
UNIX system - if you're under NT, it's anybody's guess 8-), so
DBD::Sybase can find the interfaces file.
Are you getting error messages in your error_log file ? If it can't
find the module, perl will say so. If it can't load the interfaces
file, DBD::Sybase will complain (not well, but it's different from the
first case). You may find you need to use the CGI::Carp module so your
error messages get neatly saved.
Hope this helps; Geoff
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 10 May 2000 00:14:46 -0600
From: Jeff Beard <jeff.beard@xor.com>
Subject: Re: Can a informix database manipulated by perl programming
Message-Id: <3918FE56.B7A83D3E@xor.com>
Yes. Search CPAN for the appropriate modules (DBI, DBD::Informix)
--Jeff
Joydip Chakladar wrote:
>
> Does perl have the neccesary subroutines to manipulate informix
> database Version 6.0 (Unix version) and provide functions such as add
> record modify record delete record and different operation on database
> which will be ported on web
>
> Can anybody help me on the total operation - how it would be.
>
> Thanks in advance
>
> --
> Joydip Chakladar
> http://www.allindialive.com
> From India to world
> A meeting place of surfers and webmasters
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: 9 May 2000 22:17:25 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: dns lookup on choosen name server?
Message-Id: <8f9v95$q53$1@orpheus.gellyfish.com>
On 9 May 2000 01:45:47 GMT David Efflandt wrote:
> On Mon, 08 May 2000, arne sendke <sendke@uni-paderborn.de> wrote:
>>i want to translate a url like www.amazon.com
>>into the fitting ip adress.
>
> That is not a URL, it is a hostname or alias for a hostname. But that is
> what you want to look up anyway.
>
>>gethostbyaddr doesn`t work because i want
>>to choose the name server by my script.
>
> Perhaps you should look into the Net::DNS module. I think it is included
> in the libnet package of modules.
No it comes on its own.
/J\
--
When it comes to compliments, women are ravenous blood-sucking monsters
always want'n more... more... MORE! And if you give it to them, you'll
get plenty back in return.
--
fortune oscar homer
------------------------------
Date: Wed, 10 May 2000 07:51:02 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Flame my code
Message-Id: <rl1ihssg3tq4ie2k60ae9obto03ldvgurs@4ax.com>
On 6 May 2000 22:35:44 +0100, Jonathan Stowe <gellyfish@gellyfish.com>
wrote:
>On Sat, 06 May 2000 19:09:58 +0100 Dave Cross wrote:
>> On Sat, 6 May 2000 13:24:18 -0400, "E. Preble" <preble@ipass.net>
>> wrote:
>>
>>>I have a code snippet below. Can it be better? (of course
>>>it can)
>>>
>>>purpose:
>>>Search a list of names in a array and create a new array
>>>with unique names only.
>>>For Example, if the array is:
>>>file1.txt
>>>file2.txt
>>>file2.txt
>>>file3.txt
>>>file2.txt
>>>
>>>The new array will have:
>>>file1.txt
>>>file2.txt
>>>file3.txt
>>>
>>>with NO duplicate entries of file2.txt. Here's my code
>>>(written in PerlAmateur v1.0):
>>>
>>>foreach $FileName (@File) {
>>> $found = 0;
>>> foreach $Entry (@ListOfFileNames) {
>>> if ($FileName eq $Entry) {
>>> $found=1;
>>> }
>>> }
>>> if ($found == 0) {
>>> @ListOfFileNames = (@ListOfFileNames, "$FileName");
>>> }
>>>}
>>
>> You probably want to turn your original list into a hash like this:
>>
>> my %ListofFileNames;
>> @UniqueFiles{@File} = (1) x @Files;
>>
>> and then the unique file names are the key of this hash:
>>
>> my @ListOfFileNames = keys %UniqueFiles;
>>
>
>Just 'cause you been on the piss with the 'Friends of Ken' since thursday
>night doesnt mean you can post any old stuff you know ;-}
>
>I think you had some typos in there.
>
>my %UniqueFiles;
>
>@UniqueFiles{@File} = (1) x @File;
>
>my ListOfFileNames = keys %UniqueFiles;
I think you had a small typo in there too :-)
Dave...
--
<http://www.dave.org.uk> SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>
"There ain't half been some clever bastards" - Ian Dury [RIP]
------------------------------
Date: Wed, 10 May 2000 00:10:54 -0600
From: Jeff Beard <jeff.beard@xor.com>
Subject: Re: Gotta be in the FAQ...but it doesn't seem to be...
Message-Id: <3918FD6E.5942F686@xor.com>
Use the file association on NT and the shebang on *nix. What's the
problem?
--Jeff
Eric Dew wrote:
>
> I looked at the FAQ. The closest to my question is the one in section 3
> (perlfaq3):
> How can I get '#!perl' to work on [MSDOS,NT,...]?
>
> My question is almost the same. I want to create a script which can be
> used on different systems. On each system, perl is located in different
> places. For example, on the unix system, it's located in the usual
> /usr/local/bin/perl location. So my first line in a script would be:
> #!/usr/local/bin/perl
>
> On the NT (through running cygwin), it's located in //d/usr/local/bin. Thus
> my first line is:
> #!//d/usr/local/bin/perl
>
> One way to deal with this is to use the //d/usr/local/bin/perl directory
> path and create a symlink /d -> / on the unix side.
>
> However, we have many unix machines, and many new machines keeps popping up.
> I don't want to have to go onto each unix machine and add a symlink,
> cd /
> ln -s / d
> to each one.
>
> Is there a way to provide additional paths on the #!/... line?
>
> Thanks,
>
> EDEW
------------------------------
Date: Tue, 09 May 2000 23:22:58 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Gotta be in the FAQ...but it doesn't seem to be...
Message-Id: <39190042.4EE0C256@vpservices.com>
Jeff Beard wrote:
>
> Eric Dew wrote:
> >
> > I want to create a script which can be
> > used on different systems. On each system, perl is located in different
> > places.
>
> Use the file association on NT and the shebang on *nix. What's the
> problem?
The problem is that there are some servers (notably apache) that work on
NT and require a shebang, ignoring the file association completely.
Personally, I have never found a satisfactory solution to this either,
so I am all ears.
--
Jeff
------------------------------
Date: Tue, 9 May 2000 23:59:14 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Gotta be in the FAQ...but it doesn't seem to be...
Message-Id: <MPG.1382a87570357db498aa47@nntp.hpl.hp.com>
In article <39190042.4EE0C256@vpservices.com> on Tue, 09 May 2000
23:22:58 -0700, Jeff Zucker <jeff@vpservices.com> says...
> Jeff Beard wrote:
> >
> > Eric Dew wrote:
> > >
> > > I want to create a script which can be
> > > used on different systems. On each system, perl is located in different
> > > places.
> >
> > Use the file association on NT and the shebang on *nix. What's the
> > problem?
>
> The problem is that there are some servers (notably apache) that work on
> NT and require a shebang, ignoring the file association completely.
>
> Personally, I have never found a satisfactory solution to this either,
> so I am all ears.
Set up a directory 'usr' in the root directory of the drive where the
Apache server lives. Then install ActivePerl to that directory. Now:
#!/usr/bin/perl ...
will work on NT with Apache as well as on Unix.
This assumes that on each Unixish system, the path /usr/bin/perl is
symlinked to the real perl executable. But the installation procedure
for perl should ensure that.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 May 2000 23:55:57 -0500
From: "Andrew N. McGuire" <anmcguire@ce.mediaone.net>
Subject: Re: Help Needed - Perl Matching Operator
Message-Id: <3918EBDD.C898CDB1@ce.mediaone.net>
Shell Hung wrote:
>
> There're no different of m/// and s///, for example, if you want remove
> all "@" inside the email address, you can use s/// | m///,
> $Email = "abc\@abc.com";
> $Email =~ s/\@//;
> Now, $Email = "abcabc.com";
[ snip of jeopardized post ]
There is a difference, did you even try doing 'm/\@//'
instead of 's/\@//'? The former generates a syntax error
while the latter preforms the desired substitution.
Also 's/\@//' will not remove all '@' charachters, only
the first in the string. You need to add the 'g' modifier
at the end to make it do what you said. Also I believe it
is faster to do 'tr/@//d', although I have never personally
benchmarked it.
Cheers,
anm
------------------------------
Date: Wed, 10 May 2000 14:25:14 +0800
From: Shell Hung <shell@hkscript.com>
Subject: Re: Help Needed - Perl Matching Operator
Message-Id: <391900C9.59950195@hkscript.com>
>
> There is a difference, did you even try doing 'm/\@//'
> instead of 's/\@//'? The former generates a syntax error
> while the latter preforms the desired substitution.
> Also 's/\@//' will not remove all '@' charachters, only
> the first in the string. You need to add the 'g' modifier
> at the end to make it do what you said. Also I believe it
> is faster to do 'tr/@//d', although I have never personally
> benchmarked it.
>
In this case, the s/\@// will remove the '@' character without 'g'...
On the other hand, you're right, if I using m/// will got
the syntax error. thank you !
--
*********************************************
Shell Hung - [Life - Control by yourself]
(SW E-Solutions) Analyst Programmer
(http://www.hkscript.com) Technical Director
Email : shell@hkscript.com (hkscript.com)
PGP Key : 0xC268210F (DH/DSS-1024)
*********************************************
------------------------------
Date: Wed, 10 May 2000 13:13:21 +0800
From: "wstsoi" <wstsoi@hongkong.com>
Subject: Help!! Perl and dll
Message-Id: <8faquh$i5f$1@justice.csc.cuhk.edu.hk>
Hi i want to ask that could Perl coperates with dll?
any clues?
Thanks very mcuh
------------------------------
Date: Wed, 10 May 2000 10:13:03 +0200
From: Saddek Rehal <saddek@arch.chalmers.se>
To: Jeff Zucker <jeff@vpservices.com>
Subject: Re: How can I call a perl script from html-page
Message-Id: <39191A0E.4DF2E681@arch.chalmers.se>
Thank you very much for helping me.
For the moment I have Perl ver 5.003 without cgi.pm. This require Perl 5.004.
I wonder if there is an other way for me to solve the problem without using
cgi.pm.
Thank you very much.
Saddek
Jeff Zucker wrote:
> Saddek Rehal wrote:
> >
> > My perl script start with some default variables. I would like to call
> > my script from from html-page with other variables. How can I call my
> > script from a html-page and the same time assign new values to variables
> > ???
>
> There are at least three ways to pass variables from an HTML page to a
> CGI script. They are all the same regardless of whether the script is
> written in Perl or some other langauge so you should check with a CGI
> group or documentaion if you have further questions. But the short
> answer is, either you put the variables in a link
>
> <a href="myscript.cgi?var1=foo&var2=bar"> run myscript.cgi </a>
>
> Or you put them in an HTML form as any kind of field (including hidden
> if it doesn't require user input):
>
> <form action = "myscript.cgi"
> method = "POST"
> enctype = "application/x-www-form-urlencoded">
> <input type="text" name="var1" value="foo">
> <input type="hidden" name="var2" value="bar">
> # anything else in the form
> <input type="submit">
> </form>
>
> Then, no matter how you sent them to the script, within the script you
> do something like:
>
> use CGI qw(:standard);
> print param('var1'), " ... ", param('var2');
>
> Which should print out "foo ... bar" regardless of which of the methods
> above you used to send the variables.
>
> CGI.pm comes with Perl itself so if you have Perl, you have it. It has
> tons of documentation. Please read that for further information.
>
> --
> Jeff
--
Saddek Rehal
Chalmers tekniska högskola,
Arkitektur, Byggnadskonst
412 96 Göteborg
Tel: 031-772 24 75
------------------------------
Date: 10 May 2000 04:30:42 GMT
From: abigail@foad.org (Abigail)
Subject: Re: how do I open it
Message-Id: <slrn8hhpfi.i67.abigail@ucan.foad.org>
On Thu, 04 May 2000 17:06:38 GMT, Crisper <burnt@ix.netcom.com> wrote:
++ I have a flat file database (tab delimited) that looks like this:
++
++ Date Name Address1
++ 15:27 PM Apr 12 First Name etc.
++ 00:24 AM May 13 Second Name etc.
++ 16:27 PM Jun 02 Third Name etc.
++
++ How do I open this file (using OPEN (FH, filename)) and retrive only
++ the rows with certain characteristics (for example, matching something
++ like =~/Apr/ ? )
I'd skip Perl and just use grep.
Abigail
------------------------------
Date: Wed, 10 May 2000 06:49:38 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: How many times is it found?
Message-Id: <slrn8hi1p9.k8q.garcia_suarez@r-garcia.kazibao.net>
Larry Rosler wrote in comp.lang.perl.misc:
>In article <slrn8hhbc0.efl.abigail@ucan.foad.org> on 10 May 2000
>00:29:52 GMT, Abigail <abigail@foad.org> says...
>> On Sun, 30 Apr 2000 01:52:56 +0200,
>> Penpal International <ppi@searchy.net> wrote:
>> ++ How can check how many times something is found in a string. A long time
>> ++ ago I had a script for this, but I've lost it. Example:
>> ++
>> ++ $string = "This a string with the word string. So this is just a
>> ++ string";
>> ++ # Here must come an unknown code...
>> ++
>> ++ It must result in 3 for 'string'. 2 for 'this' and all others 1 if it's
>> ++ right...
>>
>>
>> my %count;
>> map {$count {$_} ++} split /\s+/ => $string;
>
> my %count;
> $count {$_} ++ for split /\s+/ => $string;
>
>War, anyone?
Yes:
my %count;
$count {lc $_} ++ for split /\W+/ => $string;
Because it must count 'this' twice, and there is a 'This',
and because is must count 'string' three times, and there is a 'string.'.
--
Rafael Garcia-Suarez
------------------------------
Date: Wed, 10 May 2000 07:44:12 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: How many times is it found?
Message-Id: <gr8S4.11729$95.147332@news1.rdc1.mb.home.com>
In article <slrn8hi1p9.k8q.garcia_suarez@r-garcia.kazibao.net>,
Rafael Garcia-Suarez <garcia_suarez@hotmail.com> wrote:
> Larry Rosler wrote in comp.lang.perl.misc:
> >In article <slrn8hhbc0.efl.abigail@ucan.foad.org> on 10 May 2000
> >00:29:52 GMT, Abigail <abigail@foad.org> says...
[snip]
> >>
> >> my %count;
> >> map {$count {$_} ++} split /\s+/ => $string;
> >
> > my %count;
> > $count {$_} ++ for split /\s+/ => $string;
> >
> >War, anyone?
>
> Yes:
>
> my %count;
> $count {lc $_} ++ for split /\W+/ => $string;
>
> Because it must count 'this' twice, and there is a 'This',
> and because is must count 'string' three times, and there is a 'string.'.
How about:
my %count;
$count {lc $_} ++ for /\w+/g;
andrew
--
Andrew L. Johnson http://members.home.net/andrew-johnson/epwp.html
A closed mouth gathers no foot.
------------------------------
Date: Wed, 10 May 2000 08:52:52 GMT
From: sodiska@my-deja.com
Subject: How to create child process under windows ?
Message-Id: <8fb810$etd$1@nnrp1.deja.com>
Is there a way to create child and parent process under windows ? I
know that linux there is a function called fork() that can do this ,
what windows ? Can anyone please advise . Thank you .
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 10 May 2000 04:06:52 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Install Help needed Mail::Sender.pm
Message-Id: <slrn8hho3l.1hi.efflandt@efflandt.xnet.com>
On Tue, 9 May 2000 11:46:18 -0500, spurcell <skpurcell@hotmail.com> wrote:
>Does anyone out there use the Mail::Sender.pm module from jendra?
>
>If so, how do I install this module?
>On the site http://jenda.mccann.cz there are four files to grab.
>Mail::Sender.pm
>Sender.pm html
>Sender.pm.txt
>Mail-Sender-0.7.05.tar.gz
>
>So I grabbed the files, but can't figure out how to install them.
>
>Could someone help me with this?
For a Unix system you would typically get the tar.gz file, read what it
says there and it would explain how to install it.
Otherwise you just have to find some place to do the following, in one of
the directories in your @INC list (if root or admin), or most anywhere
otherwise (requires a use lib statement).
Create or use a directory called 'Mail' and put Sender.pm in it. If
the parent dir of Mail is not in your @INC paths, you will need to point
to it early in your script:
use lib '/system_path_to/mymodules';
use Mail::Sender; # or whatever options it needs
This would find /system_path_to/mymodules/Mail/Sender.pm
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Wed, 10 May 2000 09:44:31 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: Iterating an array question?
Message-Id: <8fbb1s$i09$1@nnrp1.deja.com>
In article <8f9su8$vm7$1@nnrp1.deja.com>,
yin_12180@yahoo.com wrote:
> I have an array in perl in which I'd like to run an operation only on
> every other element. Using a foreach construct, how do I iterate the
> array counter to move to the next line without using the next command.
> I.e.
>
> foreach $item (@array)
> {
> # how do iterate explicitly
> $item++; # ????
> }
>
for (my $i=0; $i < @array; $i+=2)
{
# do something with $array[$i]
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 09 May 2000 00:50:07 -0500
From: calla <torduange@geocities.com>
Subject: newbie alert: generating html output without using cgi.pm
Message-Id: <3917A70E.CE2C877A@geocities.com>
two instances to be dealt with:
in the first one, i have a stupid little hash such that
$hashref{key}= "output.html"
so all my keys correspond to htmls.
in my html form, <output value>= "key"
so i want the retrieval script to spit out the html value in the hash
when the user selects an output value. (it's a preset list of outputs
to select from). i should not need cgi.pm for this, one would think.
will a simple equality test work or even be needed, since my value *is*
an html? this is confusing me and cgi.pm is just going to be a giant
hassle to deal with on my server. if i could say "if key=output value,
return value of key", that would be handy.
the second thing:
i have another hash, same format, except the user inputs some word,
which returns a string if a match is found, or 'not found'. since the
result is a string, can i just dump a bunch of html-generating code in
my print statement and avoid dealing with cgi-anything? since i am
using tiny hashes and dbs, cgi.pm is overkill. these are like ten
element lists and 50 element dbs. even cgi-lite is overkill, since all
i need is the html-generating code, which i cannot suss from the morass
contained in cgi.pm and its little buddies.
any help would be graciously appreciated. i'm very new to perling.
s.
------------------------------
Date: Tue, 09 May 2000 23:14:18 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: newbie alert: generating html output without using cgi.pm
Message-Id: <3918FE3A.D5F76FDE@vpservices.com>
calla wrote:
>
> this is confusing me and cgi.pm is just going to be a giant
> hassle to deal with on my server.
Could you explain what kind of hassle? It comes with perl and unless
your server has a very old version of perl, it is just sitting there
waiting to be used.
> if i could say "if key=output value,
> return value of key", that would be handy.
I am not sure whether you are talking here about parsing information
from the user or sending information to the user. Please clarify and
we'll try to answer.
> since the
> result is a string, can i just dump a bunch of html-generating code in
> my print statement and avoid dealing with cgi-anything?
If you are talking about simply printing HTML with print statements, yes
definitely. Even those of us who are CGI.pm fanatics often print out
HTML strings something like this:
print <<EOP;
...
<TITLE>Some Brilliant Stuff</TITLE>
<H1>blahdeblah</H1>
blahdeblah yada yada yada
...
EOP
That's called a HERE document and lets you print a big blob of stuff
without putting in print statements or "\n"s everywhre. Using the CGI
title() method does not gain you very much over the hand-rolled method.
CGI.pm is really not needed for plain HTML (assuming you do know your
HTML rules). Where it comes in really handy is in printing tables
(where you can dump in arrays and hashes en masse), in printing forms
(sticky values and other nice stuff) which you can usually hand code if
you prefer, in using multiple-invocations of the same script (a
lifesaver in many situations and possible but klunky to do on your own)
and in reading the results of forms which you should only roll your own
if you *really* know what you are doing, and in doing stuff like
uploading files which again you should only attempt if you are aware of
all the potential security and cross-platform and other issues.
> since i am
> using tiny hashes and dbs, cgi.pm is overkill.
Overkill in what way? What does it cost you?
> the morass contained in cgi.pm
A morass in what way? It has some of the best documentation of any
module, and the really critical stuff like reading in user params is
actually far easier than any other way of doing it. Yes it has a lot of
features you may never use, but you don't need to learn them to get some
real advantage from the module.
> any help would be graciously appreciated. i'm very new to perling.
If you are new to the language, how did you gain enough expertise to
decide that CGI.pm is somehow too much of something (whatever that
something is)?
--
Jeff
------------------------------
Date: Wed, 10 May 2000 07:58:10 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Newbie brain fade
Message-Id: <391b141e.1679057@news.skynet.be>
Jonathan Young wrote:
>Ahh.. yeah, I completely forgot about that.. my bad :( How would you
>go about delimiting 'First' then? I thought about doing something like this:
>
> s/^.*?\s(?:(First)\s+(\w+)\s+(?:\w+)).*?$/$3 $2/
>
You can use \b to match between "First" and the previous stuff, because
it starts with a \w character. But a more general border detection can
easily be created by using double negative lookahead/lookbehind.
/(?<!\S)\S/
/\S(?!\S)/
This will match a nonspace preceeded with a space or the start of the
string for the first, and for the second, a nonspace followed by a space
or the end of the string.
Note that /(?!\S)/ IS NOT THE SAME as /(\?\s)/, because the latter
requires a (whitespace) character following, while the former doesn't.
All it says is that it can't be followed by a non-whitespace character.
End of string is fine, too.
Still in doubt? An example:
$_ = "This is an (unoriginal) test.";
($\, $,) = ("\n", " ");
print 'S:', /(?<!\S)(\S)/g; # starting char
print 'E:', /(\S)(?!\S)/g; # ending char
->
S: T i a ( t
E: s s n ) .
--
Bart.
------------------------------
Date: Wed, 10 May 2000 08:15:11 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Newbie brain fade
Message-Id: <391d19f2.3170710@news.skynet.be>
Bart Lateur wrote:
>Still in doubt? An example:
A slightly more elaborate example might be in order.
$_ = "This is an (unoriginal) test.";
($\, $,) = ("\n", " ");
print 'S-:', /(?<!\S)(\S)/g; # starting char, double negative
print 'S+:', /(?<=\s)(\S)/g; # starting char, positive
print 'E-:', /(\S)(?!\S)/g; # ending char, double negative
print 'E+:', /(\S)(?=\s)/g; # ending char, positive
-->
S-: T i a ( t
S+: i a ( t
E-: s s n ) .
E+: s s n )
Look how the double negative lookahead/lookbhind does one more match
than the positive lookahead/lookbehind.
--
Bart.
------------------------------
Date: Wed, 10 May 2000 00:08:01 -0600
From: Jeff Beard <jeff.beard@xor.com>
Subject: Re: Perl DBI
Message-Id: <3918FCC1.F80AAEB5@xor.com>
#!/usr/bin/perl -w
use strict;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
my $query = new CGI;
print $query->header();
my $dbh = DBI->connect("dbi:mysql:dbname", $user, $pass)
or die "Failed to connect to db: ",
$DBD::mysql::errstr;
my $sql = "SELECT * FROM tablename";
my $sth = $dbh->prepare( $sql )
or die "Error: ", $DBD::mysql::errstr;
$sth = $dbh->execute
or die "Error: ", $DBD::mysql::errstr;
while ( my ( $var1, $var2, $var3, $var4 ) = $sth->fetchrow ) {
print "$var1, $var2, $var3, $var4\n";
}
$sth->finish;
$dbh->disconnect;
Jason Malone wrote:
>
> > I don't see any print statements inside the while ()
>
> OK,
> Now the code is
>
> use DBI;
> my $dbh = DBI->connect("dbi:mysql:chamber_property","chamber","ChambP127");
> print "Content-type: text/html\n\n";
> $tabsth = $dbh->table_info();
> while ( ( $qual, $owner, $name, $type ) = $tabsth->fetchrow_array() ) {
> print $name;
> }
> $sth->finish();
>
> And it still will not work.
>
> Thanks Jason
------------------------------
Date: Wed, 10 May 2000 03:00:45 -0400
From: justin baugh <baughj@rpi.edu>
Subject: Re: Perl DBI
Message-Id: <3919091D.40CE0493@rpi.edu>
> Can someone take a look at this code and tell me what I am missing. I am
> trying to connect to a database and list the names of the tables that it
> contains.
Don't reinvent the wheel. mySQL will do this for you (in other
RDBM's this is "show fields" or some equivalent):
use DBI;
my $sql_user = "user";
my $sql_pass = "pass";
my $db_id = "dbi:mysql:<dbname>";
$dbh = DBI->connect($db_id, $sql_user, $sql_pass)
or die "Can't connect to SQL server: ", $dbh->errstr;
$table_handle = $dbh->prepare("show columns from <table name>") or die
"Error executing SQL prepare: ", $dbh->errstr;
$table_handle->execute() or die
"Error executing SQL statement: ", $dbh->errstr;
while (@table_row = $table_handle->fetchrow() ) {
print "$table_row[0]\n";
}
The @table_row you will get back will have all kinds of nice
information such as the type of data being stored, its properties,
etc. The zero element of the array holds the name. This code
will do what you require.
Hope this helps,
~j
p.s. Jeff Zucker had a good point; if this had been something
non-obvious, it becomes very difficult to detect. Don't make life
hard on yourself. BTW I highly recommend "Programming the Perl DBI"
if you're new to DBI (as it seems that you are).
--
==================================================
Justin Baugh (baughj@nocannedmeat.rpi.edu)
PGP: http://www.rpi.edu/~baughj/keys.txt
"Evil is easy, and has infinite forms." - Pascal
------------------------------
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 3000
**************************************