[16277] in Perl-Users-Digest
Perl-Users Digest, Issue: 3689 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 17 06:05:29 2000
Date: Mon, 17 Jul 2000 03:05:14 -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: <963828314-v9-i3689@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 17 Jul 2000 Volume: 9 Number: 3689
Today's topics:
.dentifying user using htaccess i <davejohnson@lansdownsoftware.co.uk>
Re: .dentifying user using htaccess i <bart.lateur@skynet.be>
Re: communicating through the location bar <gellyfish@gellyfish.com>
cpan patch to use wget <sysmwd@blackhole.detir.qld.gov.au>
Did I FLOCK this correctly? (BUCK NAKED1)
Emulating a HTML form <guymal@hotmail.com>
Re: Escaping strings. <iltzu@sci.invalid>
File::Remote module can't re-open fh radome@mailexcite.com
Re: flock nonsense ? <gellyfish@gellyfish.com>
Re: Flock unsupported on which systems? (Villy Kruse)
Re: Form problem (Haazi2)
Re: Form problem (jason)
Re: Getting a random var as output <peter.sundstrom@eds.com>
Re: Getting a random var as output <gellyfish@gellyfish.com>
Re: Help required with script <flavell@mail.cern.ch>
Re: how to make my program with csh (doco)
Re: how to make my program with csh (doco)
Re: How to read and show 10 lines <ttompkins@uswest.net>
installing XML::DOM <john_hyer_bercaw@hotmail.com>
Re: installing XML::DOM <cal@iamcal.com>
Keeping a copy of STDIN <newsgroups@justinfashanu.demon.co.uk>
Re: Keeping a copy of STDIN (jason)
Re: NEt::POP3 difficulties <gus@black.hole-in-the.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 17 Jul 2000 08:17:42 +0100
From: "Dave Johnson" <davejohnson@lansdownsoftware.co.uk>
Subject: .dentifying user using htaccess i
Message-Id: <8kuci2$he6$1@gxsn.com>
HI,
Can anyone tell me how I can pick up the identity of a user when they're
logged with password etc?
Is there some environment variable around indicating the current use's ID?
Thanks
Dave Johnson
begin 666 Dave Johnson.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..DIO:&YS;VX[1&%V90T*1DXZ
M1&%V92!*;VAN<V]N#0I.24-+3D%-13I$879E#0I/4D<Z3&%N<V1O=VX@4V]F
M='=A<F4-"E1%3#M73U)+.U9/24-%.BLT-" H,"D@,3(W,R T-S4W,30-"D%$
M4CM73U)+.CL[,C<@3&%N<V1O=VX@4&QA8V4[3&5W97,[4W5S<V5X.T).-R R
M2E4[1T(-"DQ!0D5,.U=/4DL[14Y#3T1)3D<]455/5$5$+5!224Y404),13HR
M-R!,86YS9&]W;B!0;&%C93TP1#TP04QE=V5S+"!3=7-S97@@0DXW(#)*53TP
M1#TP04="#0I%34%)3#M04D5&.TE.5$523D54.F1A=F5J;VAN<V]N0&QA;G-D
M;W=N<V]F='=A<F4N8V\N=6L-"E)%5CHR,# P,#<Q-U0P-S$W-#):#0I%3D0Z
'5D-!4D0-"@``
`
end
------------------------------
Date: Mon, 17 Jul 2000 10:48:46 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: .dentifying user using htaccess i
Message-Id: <i0i5nssuvf1d4mi4ki9gdvb52s4mf2hhqm@4ax.com>
Dave Johnson wrote:
>Can anyone tell me how I can pick up the identity of a user when they're
>logged with password etc?
>Is there some environment variable around indicating the current use's ID?
$ENV{REMOTE_USER}
--
Bart.
------------------------------
Date: 17 Jul 2000 09:02:52 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: communicating through the location bar
Message-Id: <8kuejc$b0q$1@orpheus.gellyfish.com>
On Sun, 16 Jul 2000 18:46:33 GMT Ecco wrote:
> "Keith Calvert Ivey" <kcivey@cpcug.org> wrote in message
> news:397ac4bd.138685405@news.newsguy.com...
>> "Ecco" <ecco64@chello.nl> wrote:
>>
>> >preview.pl?form_type=feedback
>> >
>> >you just need to split it up:
>> >
>> >@array = SPLIT(/=/$ENV{'QUERY_STRING'});
>> >
>> >now both "form-type" and "feedback" are stored in an array, you can work
>> >with that.
>>
>> He's already doing fine with that part. No need to persuade him
>> to take a step backward and abandon CGI.pm in favor of some
>> buggy hand-coded solution. Suppose the request ends like this:
>>
>> preview.pl?form_type=feedback&mode=create
>>
>> Then how does your method help? Just use CGI.pm (or some other
>> well-tested, supported module) -- it works.
>>
>
> YOU USE SPLIT SMARTGUY
>
There appears to be something wrong with the caps lock on your computer.
The OP was doing just fine with CGI.pm and you wade in with a partial
solution that gets him no further than he already had got.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Mon, 17 Jul 2000 04:36:25 GMT
From: Michael Dean <sysmwd@blackhole.detir.qld.gov.au>
Subject: cpan patch to use wget
Message-Id: <963808588.571036@ns1.detir.qld.gov.au>
Hellow there
I'm not sure of the procedure for getting changes put into CPAN,
but I'm always patching CPAN to use wget, so here are the changes
I make ... have fun cut'n'pasting, remember to set .
claire3:/home/src-mwd 1723 # diff -c CPAN-1.54/lib/CPAN.pm CPAN-1.54-mwd/lib/CPAN.pm
*** CPAN-1.54/lib/CPAN.pm Sun Mar 26 08:30:17 2000
--- CPAN-1.54-mwd/lib/CPAN.pm Tue Jul 4 13:00:51 2000
***************
*** 2229,2235 ****
$self->debug("localizing funkyftpwise[$url]") if $CPAN::DEBUG;
my($f,$funkyftp);
! for $f ('lynx','ncftpget','ncftp') {
next unless exists $CPAN::Config->{$f};
$funkyftp = $CPAN::Config->{$f};
next unless defined $funkyftp;
--- 2229,2235 ----
$self->debug("localizing funkyftpwise[$url]") if $CPAN::DEBUG;
my($f,$funkyftp);
! for $f ('wget','lynx','ncftpget','ncftp') {
next unless exists $CPAN::Config->{$f};
$funkyftp = $CPAN::Config->{$f};
next unless defined $funkyftp;
***************
*** 2240,2245 ****
--- 2240,2247 ----
my($source_switch) = "";
if ($f eq "lynx"){
$source_switch = " -source";
+ } elsif ($f eq "wget"){
+ $source_switch = " -O -";
} elsif ($f eq "ncftp"){
$source_switch = " -c";
}
claire3:/home/src-mwd 1726 # diff -c CPAN-1.54/lib/CPAN/FirstTime.pm CPAN-1.54-mwd/lib/CPAN/FirstTime.pm
*** CPAN-1.54/lib/CPAN/FirstTime.pm Fri Mar 24 09:27:23 2000
--- CPAN-1.54-mwd/lib/CPAN/FirstTime.pm Tue Jul 4 13:04:07 2000
***************
*** 214,220 ****
my(@path) = split /$Config{'path_sep'}/, $ENV{'PATH'};
local $^W = $old_warn;
my $progname;
! for $progname (qw/gzip tar unzip make lynx ncftpget ncftp ftp/){
if ($^O eq 'MacOS') {
$CPAN::Config->{$progname} = 'not_here';
next;
--- 214,220 ----
my(@path) = split /$Config{'path_sep'}/, $ENV{'PATH'};
local $^W = $old_warn;
my $progname;
! for $progname (qw/gzip tar unzip make lynx wget ncftpget ncftp ftp/){
if ($^O eq 'MacOS') {
$CPAN::Config->{$progname} = 'not_here';
next;
If anyone cares to add this to CPAN plz do so, (or point me in the
right direction?)
regards
mike
:)
--
--
------------------------------
Date: Mon, 17 Jul 2000 02:07:02 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Did I FLOCK this correctly?
Message-Id: <4423-3972B096-138@storefull-244.iap.bryant.webtv.net>
or is there a better way to flock it? I wrote the following code below
for a counter. Lame, I know, and I know how many of you loathe counters,
so spare me your feelings on that, if you don't mind.
The code is unique though. I wrote it so that it not only adds commas,
but adds a rd, nd, st, or th as needed, such as 31st, 1,022nd, etc. Feel
free to point out any errors/improvements. Thanks. Your response will be
greatly appreciated.
Kind Regards --DENNIS
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
open HITS, "pagehits3.dat";
#The line below LOCKS the file
flock HITS, 2;
$hits = <HITS>;
++$hits;
open(HITS,">pagehits3.dat");
print HITS $hits;
1 while $hits =~ s/(.*\d)(\d\d\d)/$1,$2/;
1 while $hits =~ s/(11$|12$|13$)/$1th/;
1 while $hits =~ s/(1$)/$1st/;
1 while $hits =~ s/(2$)/$1nd/;
1 while $hits =~ s/(3$)/$1rd/;
1 while $hits =~ s/(4$|5$|6$|7$|8$|9$|0$)/$1th/;
# The line below locks the file for 2 seconds
sleep 2;
# The following 2 lines UNLOCK the file
flock HITS, 8;
close HITS;
print <<HTML;
<DIV align='center'><font size='2' color='#66000'>You are the $hits
person to visit this website. Thanks for dropping by.</font>\n</DIV>
HTML
##END OF SCRIPT
------------------------------
Date: Mon, 17 Jul 2000 08:52:05 +0200
From: "Guy" <guymal@hotmail.com>
Subject: Emulating a HTML form
Message-Id: <8ku6t9$s46$1@news.netvision.net.il>
I'm trying to emulate a HTML POST form using a Perl script. (good for
automatic login to web services like Hotmail). I have hard coded the
original HTML form and succeeded logging in using it without problems.
Using Perl: I've succeeded opening a connection to the form action URL and
sent it the parameters it needs (name=blabla&pass=lala) but the login
doesn't work ( I get a HTML response that says something like: Object
Moved ).
I suspect it has something to do with POST/GET (The original HTML form uses
the POST method)
The code I used looks something like this:
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(POST
=>'http://www.blabla.com/scripts/login_check.asp');
$req->content_type('application/x-www-form-urlencoded');
$req->content('name=lala&pass=lulu');
my $res = $ua->request($req);
print $res->as_string;
I would greatly appreciate any help you guys have.
Thanks,
Guy
------------------------------
Date: 17 Jul 2000 07:28:06 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Escaping strings.
Message-Id: <963818251.29128@itz.pp.sci.fi>
In article <10d62c60.2407c0cf@usw-ex0102-016.remarq.com>, chuckw wrote:
>My question: How do I accept input with these characters (", ', `
>etc) without escaping them? Is there a way to render the string
>"inert" so that when it is evaluated in my SQL statement, the
>errant characters don't clog the works???
What's wrong with $dbh->quote()?
#!/usr/bin/perl -w
use strict;
use DBI;
# set appropriate values for $driver and $db!
my $dbh = DBI->connect("DBI:${driver}:${db}");
my $orig = q("foo 'bar' baz" foobar);
print "Original: $orig\n";
my $quoted = $dbh->quote($orig);
print "Quoted : $quoted\n";
my $insert = "INSERT INTO test (id, data) VALUES ('fnord', $quoted)";
print "Executing $insert\n";
$dbh->do($insert) or die "Insert statement failed";
my $select = "SELECT data FROM test WHERE id = 'fnord'";
print "Executing $select\n";
my $res = $dbh->selectcol_arrayref($select) or die "Select statement failed";
for my $result (@$res) {
print "Returned: $result\n"
}
$dbh->disconnect;
__END__
Original: "foo 'bar' baz" foobar
Quoted : '"foo \'bar\' baz" foobar'
Executing INSERT INTO test (id, data) VALUES ('fnord', '"foo \'bar\' baz" foobar')
Executing SELECT data FROM test WHERE id = 'fnord'
Returned: "foo 'bar' baz" foobar
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Mon, 17 Jul 2000 04:47:14 GMT
From: radome@mailexcite.com
Subject: File::Remote module can't re-open fh
Message-Id: <8ku34g$14u$1@nnrp1.deja.com>
Hi
I have a script that opens a remote file for reading. I am using the
File::Remote library from CPAN. When I open the file, File::Remote adds
the $fh to a hash called $File::Remote::open_handles. If I close the
file it closes ok. If I re-open it, File::Remote looks first to ensure
it's not already open. File::Remote finds it in its hash, tries to
close it and fails with "bad file descriptor". I modified my copy of
Remote.pm to delete the $fh from the hash on a successful close but I
feel I'm missing something.
Should I not be calling the close method manually?
Should I be destroying the File::Remote object after the close?
Thanks for any input.
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 Jul 2000 09:22:32 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: flock nonsense ?
Message-Id: <8kufo8$b25$1@orpheus.gellyfish.com>
On Sun, 16 Jul 2000 14:15:32 GMT John Armsby wrote:
> Why should I agonize
> with flock?
>
I really dont get this, what precisely is wrong with the documentation that
people have such difficulty with it ?
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 17 Jul 2000 09:11:18 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Flock unsupported on which systems?
Message-Id: <slrn8n5i5f.bsh.vek@pharmnl.ohout.pharmapartners.nl>
On Sat, 15 Jul 2000 10:23:47 +0200, Bart Lateur <bart.lateur@skynet.be> wrote:
>Clinton A. Pierce wrote:
>
>>> "perldoc perlport" doesn't say flock() is not supported on Windows systems... So would it be safe to
>>> assume that it IS supported?
>
>No it's not.
>
>>Systems which don't have flock() generally don't need it. (Win95/Win98)
>>The existance of flock can be tested for with eval.
>
>But that's annoying!
>
>I prefer the way the DJGPP DOS Perl handles it: flock() is simply a
>noop. If only the Win32 Perls behaved the same way. Life would be much
>nicer.
>
Except if you need to lock the file and the system just pretends that
the lock was successful when in fact it wasn't, you have a potential
problem. If you access files on a SMB share then file locking might
be very relevant, even in win9x systems.
Villy
------------------------------
Date: 17 Jul 2000 05:03:40 GMT
From: haazi2@aol.com (Haazi2)
Subject: Re: Form problem
Message-Id: <20000717010340.23105.00000429@ng-mb1.aol.com>
I do apologize for not posting the code:
Here's the HTML listing:
<html>
<head><title>sample</title><head>
<body>
<br><br>
<h1> TEST SCRIPT </h1>
<a href="/test/cgi-bin/process.pl">Test cgi script</a>
</body>
</html>
Here's the perl script:
#! /usr/local/bin/perl
# program test processing form data
use strict;
use CGI qw(:standard);
if (param()) {
my $error = 'n';
my $favorite = param("favorites");
my $name = param("name");
if ( $favorite eq "" || $name eq "" ) {
$error = 'y';
}
if ( $name =~ /\./g ) {
$error = 'y';
}
if ( $error eq 'y' ) {
print <<HTMLBEG;
Content-type: text/html
<html>
<head><title>test form</title></head>
<body>
<form method=post action="process.pl" name="testform">
<b>Please correct your errors!</b>
<p>error = $error<p>
<p>favorite = $favorite<p>
<p>name = $name<p>
<br><br>
HTMLBEG
;
if ( $favorite eq "yellow" ) {
print(" <input type=\"radio\" name=\"favorites\"
value=\"yellow\" checked> yellow <br>\n");
} else {
print(" <input type=\"radio\" name=\"favorites\"
value=\"yellow\"> yellow <br>\n");
}
if ( $favorite eq "red" ) {
print(" <input type=\"radio\" name=\"favorites\" value=\"red\"
checked> red <br>\n");
} else {
print(" <input type=\"radio\" name=\"favorites\" value=\"red\">
red <br>\n");
}
if ( $favorite eq "blue" ) {
print(" <input type=\"radio\" name=\"favorites\" value=\"blue\"
checked> blue <br>\n");
} else {
print(" <input type=\"radio\" name=\"favorites\" value=\"blue\">
blue <br>\n");
}
if ( $favorite eq "green" ) {
print(" <input type=\"radio\" name=\"favorites\" value=\"green\"
checked> green <br>\n");
} else {
print(" <input type=\"radio\" name=\"favorites\"
value=\"green\"> green <br>\n");
}
print <<HTMLEND;
<br>
<b>NAME*</b><br>
<input type="text" name="$name">
<br>
<br>
<input type="submit" value="NEXT">
</form>
</body>
</html>
HTMLEND
;
} else {
print <<MSG;
Content-type: text/html
<html>
<head><title>test form</title></head>
<body>
<br>
<br>
<h1>Thank you.</h1>
</body>
</html>
MSG
;
}
} else {
print <<BEG_HTML;
Content-type: text/html
<html>
<head><title>test form</title></head>
<body>
<form method="post" action="process.pl" name="testform">
<input type="radio" name="favorites" value="yellow"> yellow <br>
<input type="radio" name="favorites" value="red"> red <br>
<input type="radio" name="favorites" value="blue"> blue <br>
<input type="radio" name="favorites" value="green"> green <br>
<br>
<b>NAME*</b><br>
<input type="text" name="fname">
<br>
<br>
<input type="submit" value="NEXT">
</form>
</body>
</html>
BEG_HTML
;
}
When the user submits the form with the correct value the radio button is saved
but data for the name field is lost. Any ideas?
------------------------------
Date: Mon, 17 Jul 2000 06:20:54 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Form problem
Message-Id: <MPG.13dd3f756e123bb99896ce@news>
[ posted to comp.lang.perl.misc and CCed to haazi2@aol.com ]
Haazi2 wrote ..
>#! /usr/local/bin/perl
>
># program test processing form data
>use strict;
>use CGI qw(:standard);
>
>if (param()) {
> my $error = 'n';
> my $favorite = param("favorites");
> my $name = param("name");
>
> if ( $favorite eq "" || $name eq "" ) {
> $error = 'y';
> }
>
> if ( $name =~ /\./g ) {
> $error = 'y';
> }
>
> if ( $error eq 'y' ) {
> print <<HTMLBEG;
> Content-type: text/html
>
> <html>
> <head><title>test form</title></head>
> <body>
> <form method=post action="process.pl" name="testform">
> <b>Please correct your errors!</b>
> <p>error = $error<p>
> <p>favorite = $favorite<p>
> <p>name = $name<p>
> <br><br>
>HTMLBEG
>;
> if ( $favorite eq "yellow" ) {
> print(" <input type=\"radio\" name=\"favorites\"
>value=\"yellow\" checked> yellow <br>\n");
> } else {
> print(" <input type=\"radio\" name=\"favorites\"
>value=\"yellow\"> yellow <br>\n");
> }
>
> if ( $favorite eq "red" ) {
> print(" <input type=\"radio\" name=\"favorites\" value=\"red\"
>checked> red <br>\n");
> } else {
> print(" <input type=\"radio\" name=\"favorites\" value=\"red\">
>red <br>\n");
> }
>
> if ( $favorite eq "blue" ) {
> print(" <input type=\"radio\" name=\"favorites\" value=\"blue\"
>checked> blue <br>\n");
> } else {
> print(" <input type=\"radio\" name=\"favorites\" value=\"blue\">
>blue <br>\n");
> }
>
> if ( $favorite eq "green" ) {
> print(" <input type=\"radio\" name=\"favorites\" value=\"green\"
>checked> green <br>\n");
> } else {
> print(" <input type=\"radio\" name=\"favorites\"
>value=\"green\"> green <br>\n");
> }
>
> print <<HTMLEND;
> <br>
> <b>NAME*</b><br>
> <input type="text" name="$name">
> <br>
> <br>
> <input type="submit" value="NEXT">
> </form>
> </body>
> </html>
>HTMLEND
>;
> } else {
> print <<MSG;
> Content-type: text/html
> <html>
> <head><title>test form</title></head>
> <body>
> <br>
> <br>
> <h1>Thank you.</h1>
> </body>
> </html>
>MSG
>;
> }
>
>} else {
>
> print <<BEG_HTML;
> Content-type: text/html
>
> <html>
> <head><title>test form</title></head>
> <body>
> <form method="post" action="process.pl" name="testform">
> <input type="radio" name="favorites" value="yellow"> yellow <br>
> <input type="radio" name="favorites" value="red"> red <br>
> <input type="radio" name="favorites" value="blue"> blue <br>
> <input type="radio" name="favorites" value="green"> green <br>
> <br>
> <b>NAME*</b><br>
> <input type="text" name="fname">
> <br>
> <br>
> <input type="submit" value="NEXT">
>
> </form>
> </body>
> </html>
>
>BEG_HTML
>;
>
>}
so .. let me remind the viewers of the problem (which fortunately I
remember) .. you click on the link and the script produces a form to be
filled in .. when you fill it in the first time - the text field doesn't
seem to get into the script correctly .. but when you submit the form
the second time (and subsequent times) the values find their way into
your script
your problem arises because your script is expecting param("name") to
give the value of the text field .. but the 'else' clause of your script
outputs the following HTML
<input type="text" name="fname">
so .. the first time the form is produced for the browser the text field
is called "fname" .. but your script is wanting "name" .. hence it gets
no value
a warning .. the second time - the name of the text field is the VALUE
of the text field from the submission .. so on the second and subsequent
submissions if you put anything other than "name" in that text field
then the script would also not work
at the risk of giving you an answer that prevents you from learning ..
but in the hope of showing you some things for your program .. here's
how I would code your logic using the same output method that you're
using - because it would actually be better to use the CGI module's
output methods .. but one thing at a time
note the flow of the code .. you have three paths through your code ..
one where the code is being executed for the first time .. one where
there's an error .. and the default code path where you've got the
values you need and just send a thank you .. I think you'll agree that
it's clearer having these paths as separate subroutines - rather than in
large nested conditionals
there are also some corrections .. the HTTP headers should not have
leading spaces .. and your "thank you" output didn't have a blank line
between the headers and the HTML
and one functionality alteration - the $error code is not output ..
because if we're in that path of code then it will always be the same
thing
#!/usr/local/bin/perl
use strict;
use CGI qw(:standard);
my $favorite = param('favorite');
my $name = param('name');
# is this the first time this script has been called ?
first() unless defined $favorite and defined $name;
# check the values of those vars and make sure there's no '.' in $name
error() if $favorite eq '' or $name eq '' or index( $name, '.') > -1;
# if it was all ok then say thank you
print <<__END;
Content-type: text/html
<html>
<head><title>test form</title></head>
<body>
<br>
<br>
<h1>Thank you.</h1>
</body>
</html>
__END
sub error
{
print <<__END;
Content-type: text/html
<html>
<head><title>test form</title></head>
<body>
<form method=post action="process.pl" name="testform">
<b>Please correct your errors!</b>
<p>favorite = $favorite<p>
<p>name = $name<p>
<br><br>
__END
# loop through the four radio values testing and checking as we go
for( qw/yellow red blue green/ )
{
print qq[ <input type="radio" name="favorite" value="$_"]
, ( $_ eq $favorite ? ' checked' : '' )
, qq[> $_ <br>\n]
;
}
print <<__END;
<br>
<b>NAME*</b><br>
<input type="text" name="name" value="$name">
<br>
<br>
<input type="submit" value="NEXT">
</form>
</body>
</html>
__END
exit;
}
sub first
{
print <<__END;
Content-type: text/html
<html>
<head><title>test form</title></head>
<body>
<form method="post" action="process.pl" name="testform">
<input type="radio" name="favorite" value="yellow"> yellow <br>
<input type="radio" name="favorite" value="red"> red <br>
<input type="radio" name="favorite" value="blue"> blue <br>
<input type="radio" name="favorite" value="green"> green <br>
<br>
<b>NAME*</b><br>
<input type="text" name="name">
<br>
<br>
<input type="submit" value="NEXT">
</form>
</body>
</html>
__END
exit;
}
__END__
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Mon, 17 Jul 2000 16:57:27 +1200
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Getting a random var as output
Message-Id: <8ku3p5$ahc$1@hermes.nz.eds.com>
Ecco wrote in message ...
>That's wat I needed. Thanx. And Tad, sorry for not feeling like spitting
>through an FAQ, I hate those things.
Yeh. They serve no purpose at all. Why do people even bother to write
them?
------------------------------
Date: 17 Jul 2000 09:37:56 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Getting a random var as output
Message-Id: <8kugl4$b32$1@orpheus.gellyfish.com>
On Sun, 16 Jul 2000 18:51:20 GMT Ecco wrote:
> That's wat I needed. Thanx. And Tad, sorry for not feeling like spitting
> through an FAQ, I hate those things.
Thanks fo telling us that.
*plonk*
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Mon, 17 Jul 2000 11:26:24 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Help required with script
Message-Id: <Pine.GHP.4.21.0007171124260.6501-100000@hpplus03.cern.ch>
On 17 Jul 2000, ShadowNateY2K wrote:
> Can anyone offer assistance with this script?
CGI.pm, and the other advice frequently posted to this group.
------------------------------
Date: 17 Jul 2000 08:48:33 GMT
From: is83024@cis.nctu.edu.tw (doco)
Subject: Re: how to make my program with csh
Message-Id: <8kuh91$2op$1@news.cis.nctu.edu.tw>
Drew Simonis (care227@attglobal.net) 提到:
Thank you.
--
*
I can see through the star into your heart * *
So no mater where you are , it's never far
. . I hold you in my soul you always be
Here with me forever you must believe
I am wating for you *
I am wating for you in my heart.......
*.
------------------------------
Date: 17 Jul 2000 08:57:06 GMT
From: is83024@cis.nctu.edu.tw (doco)
Subject: Re: how to make my program with csh
Message-Id: <8kuhp2$2op$2@news.cis.nctu.edu.tw>
Drew Simonis (care227@attglobal.net) 提到:
: doco wrote:
: > Drew Simonis (care227@attglobal.net) 提到:
: > I need to know "Redirect the standard output to a file" under PERL
: > using "csh" commands,not "sh".
: > Tell me in details,please. Thx.
: Perl uses sh when it executes external commands via any of the means
: I've specified. And besides, you shouldn't be trying to use csh
: syntax in Perl, thats backwards. If you are going to use Perl,
: USE it. You'll find Perl is much more powerfull than csh once you
: get a little more comfortable.
PERL FAQ8
How do I make my program run with sh and csh?
See the eg/nih script (part of the perl source distribution).
--
*
I can see through the star into your heart * *
So no mater where you are , it's never far
. . I hold you in my soul you always be
Here with me forever you must believe
I am wating for you *
I am wating for you in my heart.......
*.
------------------------------
Date: Mon, 17 Jul 2000 00:38:58 -0700
From: "Tim Tompkins" <ttompkins@uswest.net>
Subject: Re: How to read and show 10 lines
Message-Id: <qtAc5.49$7Y2.11698@news.uswest.net>
There are two main approaches to this problem depending upon the
application.
1. Reading N consecutive rows from an arbitrary starting point, and
finishing.
2. Paging through the entire datafile N rows at a time; continuing with
valid user input.
Approach 1: Reading N consecutive rows from an arbitrary starting point, and
finishing.
Given:
page_size => $page,
start_point => $start,
data_file => $filename
------- Begin Script -------
#!/usr/bin/perl
use strict;
my $page = 10;
my $start = $ARGV[0];
my $filename = '/path/to/data/file';
my @data = read_lines($page, $start, $filename);
for my $line (@data) {
# call parse_data() on $line and print it
my $data = parse_data( $line );
# assuming $data is a hashref...
print join (', ', map { "$_ => $data->{$_}" } (keys %$data)), "\n";
}
sub read_lines {
my ($p,$s,$f) = @_;
$p ||= 10;
$s ||= 1;
(-e $f) || die("File, $f, does not exist.\n");
local(*FH);
open(FH, $f) || die("Unable to read $f: $!\n");
my $row = 0;
my @lines;
while(<FH>) {
next unless ++$row >= $s;
push @lines, $_;
last if @lines == $p;
}
close(FH);
chomp(@lines);
return(@lines);
}
sub parse_data {
my $line = shift;
# Add your code here to split out the data fields
# This application assumes that you will be returning a hash reference.
# Its construct may be similar to the following:
# Pipe delimeted key=value fields -- "key1=25|key2=value 2|key3=hello
world"
my $dat = {};
for my $pair ( split /\|/, $line ) {
my($key,$val) = ( split /=/, $pair );
$dat->{$key} = $val;
}
return $dat;
}
__END__
Approach 2:
given:
page_size => $page,
start_point => $start,
data_file => $filename
------- Begin Script -------
#!/usr/bin/perl
use strict;
$| = 1;
my $page = 10;
my $start = $ARGV[0];
my $filename = '/path/to/data/file';
open(FH, $filename) || die("Unable to open $filename: $!\n");
my $on = 0;
while (my $line = <FH>) {
my $data = parse_data( $line );
# assuming $data is a hashref...
print ++$on, ". ", join (', ', map { "$_ => $data->{$_}" } (keys
%$data)), "\n";
if ($on % $page == 0) {
print "Continue? (Y/n) \n> ";
my $yn = <>;
last if $yn =~ /n/i;
}
}
sub parse_data {
my $line = shift;
# Add your code here to split out the data fields
# This application assumes that you will be returning a hash reference.
# Its construct may be similar to the following:
# Pipe delimeted key=value fields -- "key1=25|key2=value 2|key3=hello
world"
my $dat = {};
for my $pair ( split /\|/, $line ) {
my($key,$val) = ( split /=/, $pair );
$dat->{$key} = $val;
}
return $dat;
}
__END__
NOTE:
Approach 1 will work for either CGI or command line while approach 2 will
work only on the command line. You'll obviously want to use a CGI param
instead of %ARGV for the starting point (see: perdoc CGI ).
Thanks,
Tim Tompkins
----------------------------------------------
Programmer / Staff Engineer
http://www.arttoday.com/
----------------------------------------------
------------------------------
Date: Sun, 16 Jul 2000 21:44:39 -0700
From: "Hyer Bercaw" <john_hyer_bercaw@hotmail.com>
Subject: installing XML::DOM
Message-Id: <39728eec_2@news.nwlink.com>
I have used PPM to successfuly install XML::DOM on Win98, but I keep getting
errors when I try to install it on Win2000. Any ideas?
Thanks,
Hyer
------------------------------
Date: Mon, 17 Jul 2000 10:49:19 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: installing XML::DOM
Message-Id: <jEAc5.2787$Pj1.67866@news2-win.server.ntlworld.com>
"Hyer Bercaw" <john_hyer_bercaw@hotmail.com> wrote:
: I have used PPM to successfuly install XML::DOM on Win98, but I keep getting
: errors when I try to install it on Win2000. Any ideas?
:
: Thanks,
:
: Hyer
Which errors in particular?
--
Cal Henderson
sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);
------------------------------
Date: Mon, 17 Jul 2000 07:33:25 +0100
From: "Rob Sedgwick" <newsgroups@justinfashanu.demon.co.uk>
Subject: Keeping a copy of STDIN
Message-Id: <963815928.3722.0.nnrp-08.d4e4e97b@news.demon.co.uk>
I would be grateful if someone in the know can help me with this problem. I
have a Perl CGI script which is used to process a HTML form. The script also
uses a Perl library file, cgi-lib.pl. Both are trying to exclusively access
STDIN, what I need to do is make a copy of it or somehow share it between
them.
Critical lines from my script:
require "./cgi-lib.pl";
$inpstr = <STDIN>;
Critical line from: cgi-lib.pl
if (($got = read(STDIN, $in, $len) != $len))
Scope comes to mind? Does a variable that is created in an external script
still exist in my local script? Or am I missing something really basic?
Any help is very much appreciated.
Rob
------------------------------
Date: Mon, 17 Jul 2000 06:54:55 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Keeping a copy of STDIN
Message-Id: <MPG.13dd4b13d457a8799896d1@news>
Rob Sedgwick wrote ..
>I would be grateful if someone in the know can help me with this problem. I
>have a Perl CGI script which is used to process a HTML form. The script also
>uses a Perl library file, cgi-lib.pl. Both are trying to exclusively access
>STDIN, what I need to do is make a copy of it or somehow share it between
>them.
>
>Critical lines from my script:
>
>require "./cgi-lib.pl";
>
>$inpstr = <STDIN>;
>
>Critical line from: cgi-lib.pl
>
>if (($got = read(STDIN, $in, $len) != $len))
>
>Scope comes to mind? Does a variable that is created in an external script
>still exist in my local script? Or am I missing something really basic?
why are you using cgi-lib.pl if you're going to handle STDIN yourself ?
.. in fact - why are you using it at all when the standard module CGI.pm
handles things much more gracefully
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Mon, 17 Jul 2000 08:14:17 GMT
From: Gus <gus@black.hole-in-the.net>
Subject: Re: NEt::POP3 difficulties
Message-Id: <963821657.6404.0.nnrp-12.c29f015a@news.demon.co.uk>
In comp.lang.perl.modules Somebody Special <someone@msn.com> wrote:
> But when I try to dereference the result of
> my $msgList = $pop3->list();
> I cannot access the has table -- the documentation says that this is a
> reference to a hash table...
$pop = Net::POP3->new($host);
$num = $pop->login($user,$pass);
*msglist = $pop->list();
foreach $number (keys %msglist) {
print "Message number ", $number, " is ", $msglist{$number} , " bytes\n";
}
Regards,
_Gus
--
gus@black.hole-in-the.net
0x58E18C6D
82 AA 4D 7F D8 45 58 05 6D 1B 1A 72 1E DB 31 B5
http://black.hole-in-the.net/gus/
------------------------------
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 3689
**************************************