[15642] in Perl-Users-Digest
Perl-Users Digest, Issue: 3055 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 15 21:05:38 2000
Date: Mon, 15 May 2000 18: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: <958439115-v9-i3055@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 15 May 2000 Volume: 9 Number: 3055
Today's topics:
"bind: Invalid argument" makes me say "huh?" <elijah@workspot.net>
Re: [RegExp] Specific or General, which is faster? (Tad McClellan)
Re: Access from several Perl-Scripts on one variable? <thepoet1@arcormail.de>
Re: Annoying -w messages from standard distributed modu <rootbeer@redcat.com>
Re: Change list another way ? <makarand_kulkarni@My-Deja.com>
Re: Color with Windows NT <rootbeer@redcat.com>
Re: counter <thepoet1@arcormail.de>
Re: counter <lr@hpl.hp.com>
Re: counter (Abigail)
Re: Creating mail accounts on Linux with Perl <rootbeer@redcat.com>
Re: Creating mail accounts on Linux with Perl <jeff@vpservices.com>
Re: Do YOU use taint-checking? <tony_curtis32@yahoo.com>
Re: File exists <makarand_kulkarni@My-Deja.com>
Re: File exists (Randal L. Schwartz)
Re: File exists (Charles DeRykus)
Re: File lock? Help Needed!! <thepoet1@arcormail.de>
Re: File Upload and Multiple selection drop downs??? <rootbeer@redcat.com>
Re: Forms with Perl <thepoet1@arcormail.de>
Re: How to COPY a website <thepoet1@arcormail.de>
Re: How to test perl CGI scripts on my computer first? ()
Re: Initializing variables <rootbeer@redcat.com>
LWP POST and send cookies yahya95@hotmail.com
Odd fork() problem <sgifford@tir.com>
Re: PERL on CDROM <rootbeer@redcat.com>
Re: perl on OS390 <rootbeer@redcat.com>
Re: perl script to manage sendmail? <thepoet1@arcormail.de>
Re: Perl vs ActivePerl <rootbeer@redcat.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 May 2000 22:34:51 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: "bind: Invalid argument" makes me say "huh?"
Message-Id: <eli$0005151820@qz.little-neck.ny.us>
I posted a question based on this last week and (tweaking Net::DNS)
and got no response. So I thought maybe I should ask it better.
Below is a small script that demonstrates the problem. When I
run it (5.005_03 on Linux and 5.004_03 on SunOS4) I get the
following error:
bind: Invalid argument at test-bind.pl line 28.
The use of bind on line 28 looks quite reasonable to me.
#!/usr/local/bin/perl5.00403 -w
# Test bind problem
use strict;
use Socket;
use IO::Socket;
use IO::Select;
use vars qw ( $each $eport $sport @hosts );
$sport = 13579;
$eport = 2468;
@hosts = qw( 127.1 172.24.1.100 );
foreach $each (@hosts) {
my $sock =
IO::Socket::INET->new(PeerAddr => $each,
PeerPort => $eport,
Proto => "udp");
if ($sport and $sock) {
$sock->setsockopt(SOL_SOCKET,SO_REUSEADDR, pack('l', 1))
or die "setsockopt: $!";
my $saddr = sockaddr_in($sport, INADDR_ANY)
or die "sockaddr_in: $!";
$sock->bind($saddr) # line 28
or die "bind: $!";
}
unless (defined($sock)) {
warn "Sock from $sport to $each:$eport broken";
next;
}
print STDERR "Created & bind'ed socket to $each:$eport from $sport\n";
}
__END__
In other code, which does not use IO::Socket or IO::Select, I
can do the equivilent (create a udp socket, set reuse address,
bind to a port, connect, send data). In this case I'm just
trying to change the way the send_udp() sub works in Net::DNS's
Resolver.pm, since I want to use a fixed source port for
firewall reasons. I don't want to rewrite Net::DNS to not be
so OO.
Elijah
------
has already solved this for his need by patching dig and parsing dig's output
------------------------------
Date: Mon, 15 May 2000 17:24:51 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: [RegExp] Specific or General, which is faster?
Message-Id: <slrn8i0qp3.1ju.tadmc@magna.metronet.com>
On Mon, 15 May 2000 22:36:06 +0200, Charles Henry <charles.henry@engineer2k.com> wrote:
>> You missed the most obvious solution: substr.
>
>"substr" ??
^ ^ ^^
^ ^ ^^
You have too much punctuation there.
Type this instead at a command line:
perldoc -f substr
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 15 May 2000 23:06:01 +0200
From: Christian Winter <thepoet1@arcormail.de>
Subject: Re: Access from several Perl-Scripts on one variable?
Message-Id: <propf8.905.ln@usenet-autoren.de>
Thorsten <thorsten_kuske@gmx.net> schrob:
> Is it possible to access from several Perl-Scripts on one variable?
> I would be really glad if you could answer me that question and how to do
> so, because this would mean to me to save several hours of work.
Maybe you can specify a little more, what you want to do. Where
does the variable stem from, do the scripts invoke each other or
are they started separately, do they run in the same environment...
Questions over Questions.
Regards
Christian
------------------------------
Date: Mon, 15 May 2000 16:14:27 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Annoying -w messages from standard distributed modules
Message-Id: <Pine.GSO.4.10.10005151541300.25459-100000@user2.teleport.com>
On Mon, 15 May 2000, John Lin wrote:
> Constant subroutine emptyenum redefined
> at D:/Perl/site/lib/Win32/OLE/Const.pm line 65535.
>
> Hey, D:/Perl/site/lib/Win32/OLE/Const.pm has only 187 lines.
> Last time I got another error reported at DBD::Oracle line 0.
> Line 0? Yes.
Hey, every program has a bug. perl is a program. Therefore, Socrates is a
bug. :-)
> Since the warnings are carped from standard distributed modules,
> it is inappropriate for us to modify the source code to fix it.
Who says? But when you fix a bug, be sure to send the patch to perlbug.
> Then, can we ask for a -w option that shuts up those carps from
> other modules we use, and just warn the errors in our own code?
Sure; spell it -Mwarnings . :-)
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 15:09:42 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Change list another way ?
Message-Id: <392075A6.C89B6FF9@My-Deja.com>
Hans wrote:
> Hi,
>
> I want to put some vars in a list :
>
> $msg_in->attach(
> Type =>$tpe_file,
> Encoding =>$enc_file,
> Path =>$nam_file);
>
> this won't work but
>
> ${$msg_in->{"Type"}} = $tpe_file;
> ${$msg_in->{"Encoding"}} = $enc_file;
> ${$msg_in->{"Path"}} = $nam_file;
>
> should work. How is it done in the first list ?
>
use Data::Dumper ;
my $tpe_file='tpe';
my $enc_file='enc';
my $nam_file='nam';
${$msg_in->{"Type"}} = $tpe_file;
${$msg_in->{"Encoding"}} = $enc_file;
${$msg_in->{"Path"}} = $nam_file;
print Dumper $msg_in ;
# can also be written as ..
$msg = {
'Type' => \$tpe_file,
'Path' => \$enc_file ,
'Encoding' => \$nam_file
} ;
print Dumper $msg ;
exit ;
--
------------------------------
Date: Mon, 15 May 2000 17:09:23 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Color with Windows NT
Message-Id: <Pine.GSO.4.10.10005151707470.25459-100000@user2.teleport.com>
On Mon, 15 May 2000, Aurelien wrote:
> Newsgroups: comp.lang.perl.misc
> Subject: Color with Windows NT
> I have problem to use color with Windows NT. I know how to use color.
> Someone tell me that I just have to add the
> "DEVICE=c:/Winnt/system32/ansi.sys" command in the
> c:/Winnt/system32/config.nt file but it doesn't work.What is the
> correct file or the correct command ? Thanks to answer me.
This doesn't sound like a perl problem. Perhaps you want to search for the
docs, FAQs, and newsgroups about Windows NT and how to configure it.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 22:05:36 +0200
From: Christian Winter <thepoet1@arcormail.de>
Subject: Re: counter
Message-Id: <galpf8.8g4.ln@usenet-autoren.de>
Abigail <abigail@foad.org> schrob:
> ++ and I can never get it to work.
> That's because you don't have semicolons after etc.
nice one :-(
It's because of the semicolon at line 18 (after the if-clause and
before the '{' ).
One problem of this script is, that user entries aren't expired after
some time, but same IPs may occur again given to other users.
Another one is that $ENV{"REMOTE_USER"} isn't set on many systems,
a little better is $ENV{"REMOTE_ADDR"}.
Here is a slightly modified version, also including the "-w" switch
(verbose syntax checking) and CGI::Carp to get error messages to
the browser and not just into some hidden log. Both items may be
removed after some time of successful testing.
Additionally, I included some file locking to prevent data files
from getting messed up by two instances of the script writing
simultaneously to them.
(Basic testing already done on linux+apache and solaris+apache).
-----------------------hitcount.cgi-------------------------------
#!/usr/bin/perl -w
#
# This script is written by Chr. Winter <thepoet1@thepoet1.de>
# It is based on a script from edbubbleluk@hotmail.com
# This script is freeware. Feel free to use, modify and distribute
# it.
#
# You can download this script at
# http://www.linux-config.de/cgi-bin/shlpage.cgi?page=scripts.html&txt=no
#
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Fcntl qw(:flock);
my @visitors;
my @dates;
my $hitsfile = "/home/httpd/hits.dat"; # or somewhere else
my $visitorsfile = "/home/httpd/visitors.dat"; # or somewhere else
# The two files hits.dat and visitors.dat should be created before
# starting the script the first time, hits.dat containing nothing
# but a zero (0) char.
#
# Best would be to put both .dat-files out of the web-reachable
# directory, e.g. if you have a virtual account at a server rooted
# at /home/~username/WWW then put it under /home/~username and
# give this paths to the script.
#
# chmod them to 644 (rw-r--r--) and chown them to user www, httpd
# or nobody if none of the first two is available.
my $expires_after = 2 * 3600; # 2 hours = 2 * 3600 seconds
my $query=new CGI;
open( HIT, "+<$hitsfile" ) or die $!;
sleep 1 until (flock HIT, LOCK_EX);
# lock the file, otherwise counter could be incremented by other
# visitors and then set to a value too low by this one
my $hitcount = <HIT>;
chomp $hitcount;
open( VIS, "+<$visitorsfile" ) or die $!;
sleep 1 until (flock VIS, LOCK_EX);
# same here, but effects of two scripts writing simultaneosly
# could be even worse.
while (<VIS>)
{
my ($date, $name) = split '==', $_;
if( time-$date < $expires_after )
{
# only compare entries that haven't yet expired!
push @visitors, $name;
push @dates, $date;
}
}
chomp @visitors;
if ( @visitors && "@visitors" =~ /$ENV{"REMOTE_ADDR"}/)
{
# 'if ( @visitors &&' is tested because visitors.dat may be empty
# at the first run
foreach( 0..$#visitors )
{
# update user entry to actual time as last visit
$dates[$_] = time if ( $visitors[$_] eq $ENV{"REMOTE_ADDR"} );
}
flock HIT, LOCK_UN;
close HIT;
}
else
{
push @visitors, $ENV{"REMOTE_ADDR"};
push @dates, time;
$hitcount++;
seek( HIT, 0, 0 );
print HIT $hitcount;
flock HIT, LOCK_UN;
close HIT;
}
seek( VIS, 0 , 0 );
foreach( 0..$#visitors )
{
# rewrite all visitors into file
print VIS "$dates[$_]==$visitors[$_]\n";
}
flock VIS, LOCK_UN;
close VIS;
print $query->header(),"\n\n";
print $hitcount;
exit 0;
----------------------------------------------------------------
This script should only be used on sites with "low traffic", that
means less than about 800 hits per day, due to memory issues.
Every time someone activates the script the whole user list is
loaded into memory. If there are more hits I
would recommend to use a database (like MySQL, many provider give
you access to this) to store user data.
If anyone really needs this he may contact me.
HTH
Christian
------------------------------
Date: Mon, 15 May 2000 16:47:34 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: counter
Message-Id: <MPG.138a2c70a11ac8f698aa86@nntp.hpl.hp.com>
In article <galpf8.8g4.ln@usenet-autoren.de> on Mon, 15 May 2000
22:05:36 +0200, Christian Winter <thepoet1@arcormail.de> says...
...
> #!/usr/bin/perl -w
use strict; # But your coding style seems to conform to it already.
...
> if ( @visitors && "@visitors" =~ /$ENV{"REMOTE_ADDR"}/)
Perhaps this is a little better: /\b\Q$ENV{REMOTE_ADDR}\E\b/
> {
> # 'if ( @visitors &&' is tested because visitors.dat may be empty
> # at the first run
That really shouldn't matter.
> foreach( 0..$#visitors )
> {
> # update user entry to actual time as last visit
> $dates[$_] = time if ( $visitors[$_] eq $ENV{"REMOTE_ADDR"} );
> }
> flock HIT, LOCK_UN;
Unlocking the file before closing it is not recommended.
> close HIT;
> }
> else
> {
> push @visitors, $ENV{"REMOTE_ADDR"};
> push @dates, time;
>
> $hitcount++;
>
> seek( HIT, 0, 0 );
Test for success.
> print HIT $hitcount;
> flock HIT, LOCK_UN;
Unlocking the file before closing it is not recommended.
> close HIT;
> }
>
> seek( VIS, 0 , 0 );
Test for success.
> foreach( 0..$#visitors )
> {
> # rewrite all visitors into file
> print VIS "$dates[$_]==$visitors[$_]\n";
> }
> flock VIS, LOCK_UN;
Unlocking the file before closing it is not recommended.
> close VIS;
Nice job. I'm sure it will make a lot of people happier than some of
the stuff now posted, such as Matt Wright's golden oldies.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 May 2000 00:46:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: counter
Message-Id: <slrn8i16je.dco.abigail@ucan.foad.org>
On Mon,
15 May 2000 22:05:36 +0200, Christian Winter <thepoet1@arcormail.de> wrote:
++
++ sleep 1 until (flock HIT, LOCK_EX);
This is strange. Unless told otherwise, flock() will block untill
it has the lock - or a failure occurs. The only time flock() will
return false on a blocking call, is when the flock() fails because
of an error condition; not because it has to wait for a lock. Blindly
sleeping a second and retrying isn't good.
flock HIT, LOCK_EX or die "flock failed: $!";
++ if ( @visitors && "@visitors" =~ /$ENV{"REMOTE_ADDR"}/)
That gets expensive after a while. Why not
if (grep {$_ eq $ENV {REMOTE_ADDR}} @visitors)
which will neither build a long string, nor uses the regex machine.
On top of that, it won't create a false positive if @visitors contains
'127.0.0.100' and $ENV {REMOTE_ADDR} equals '127.0.0.1'.
Of course, using a dbm file would be much more efficient.
Abigail
------------------------------
Date: Mon, 15 May 2000 17:27:58 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Creating mail accounts on Linux with Perl
Message-Id: <Pine.GSO.4.10.10005151726340.25459-100000@user2.teleport.com>
On Mon, 15 May 2000, AcCeSsDeNiEd wrote:
> Does anyone know how to create mail accounts on Linux RedHat6.2 with
> Perl?
Sure; do it the same way you'd do it without Perl. :-)
That's a lot like asking, "Does anyone know how to drive to Disneyland in
a Toyota?"
> It's running sendmail. I'm not too familiar with spoiling but should
> the accounts be spooled here: /var/spool/mail ?
Maybe you should be searching for the docs, FAQs, and newsgroups about
sendmail.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 17:32:54 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Creating mail accounts on Linux with Perl
Message-Id: <39209736.B9C55B66@vpservices.com>
Tom Phoenix wrote:
>
>
> > Does anyone know how to create mail accounts on Linux RedHat6.2 with
> > Perl?
>
> That's a lot like asking, "Does anyone know how to drive to Disneyland in
> a Toyota?"
>
And earlier in another thread:
> Perl doesn't have menus, any more than an airplane has vacations.
Oh my, two entries in the FAIQ in one day.
--
Jeff
------------------------------
Date: Mon, 15 May 2000 22:05:29 GMT
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Do YOU use taint-checking?
Message-Id: <87itwflb9y.fsf@shleppie.uh.edu>
>> On Mon, 15 May 2000 20:15:48 GMT,
>> webqueen, queen of the web <webqueen@my-deja.com> said:
> I avoid system() and `` calls and try to stick to things
> that are safe, yet -T seems to complain about almost
> everything.
OK, then post some of your code (e.g. a made-up example
demonstrating some taint warnings you've seen before) and
then the taint-enabled in clpm can point out what to do.
> but I still wonder is it worth the effort to dig through
> mega-lines of Perl to fix a plethora of possible
> security issues which in my mind (particularly given the
> cgi-wrapper on our servers) are extremely remote. In my
"extremely remote" security issues on the net happen all
the time (<reference type=pratchett>especially if it's a
million to one shot</reference>). Usually when it's most
incovenient.
> So, again, are YOU a taint-checker?
Yes, but not always. By which I mean: if I'm writing a
simple script for myself on my laptop to do something and
I know the full context in which it will be used, I will
probably not taint-check.
If however, the program is to be used on-line and/or by
anyone else then I will definitely -cwT it often during
development.
hth
t
------------------------------
Date: Mon, 15 May 2000 15:19:05 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: File exists
Message-Id: <392077D9.56362546@My-Deja.com>
shoaibq@my-deja.com wrote:
> I have a file in a directory and what i am trying to do is check for
> it's existence. I know the -e operator works but the thing is that the
> filename that i will search for will change from time to time. Only the
> first two letters of the filename will remain the same. i tried:
>
> $fname = "aa" . "\*\.\*";
> if (-e "$fname") {
> printf(STDOUT "File exists");
> }
> else {
> printf(STDOUT "Not found");
> }
>
> Any suggestions?
use readdir() to get directory listing and then decided for yourself
if that file exists..
Example, to look at the current directory to see if there
are files that start with "aa" in the name..
$this_dir= './';
opendir(DIR, $this_dir) || die "can't opendir: $!";
@files = grep { /^aa/ && -f "$this_dir/$_" } readdir(DIR);
# @files is the list of files that has filenames starting with "aa".
closedir DIR;
if ( scalar ( @files ) )
{
print "file(s) exists(s)..\n"
}
else
{
print "no file(s) exist(s)..\n"
}
~
------------------------------
Date: 15 May 2000 15:47:13 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: File exists
Message-Id: <m1u2fzl9ce.fsf@halfdome.holdit.com>
>>>>> "Makarand" == Makarand Kulkarni <makarand_kulkarni@My-Deja.com> writes:
While the rest of your post is good, I must take note of this line:
Makarand> if ( scalar ( @files ) )
What is that "scalar" doing there? It is perhaps cargo-cult
programming, which I'm obligated to clean up for damage control
purposes. The boolean expression of the if is already in a scalar
context. This would be similar to saying "+3" instead of "3" all the
time, "just to make sure it's positive". No point. Voodoo.
Cargo-cult. Please stop.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 15 May 2000 22:54:20 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: File exists
Message-Id: <FuMIAK.9Cx@news.boeing.com>
In article <8fpod4$3dr$1@nnrp1.deja.com>, <shoaibq@my-deja.com> wrote:
>I have a file in a directory and what i am trying to do is check for
>it's existence. I know the -e operator works but the thing is that the
>filename that i will search for will change from time to time. Only the
>first two letters of the filename will remain the same. i tried:
>
>$fname = "aa" . "\*\.\*";
>if (-e "$fname") {
>printf(STDOUT "File exists");
>}
>else {
>printf(STDOUT "Not found");
>}
>
There are several ways. Here're a couple
you can check out:
perldoc -f readdir
perldoc -f glob
Also there's a new File::Glob module in
Perl 5.6 but that may be more than you
need.
Probably, the easiest but slowest and
least desirable:
my @fnames = </dir/path/to/aa*>;
See perldoc perlop and look for I/O Operators
which will explain why.
--
Charles DeRykus
------------------------------
Date: Mon, 15 May 2000 22:52:54 +0200
From: Christian Winter <thepoet1@arcormail.de>
Subject: Re: File lock? Help Needed!!
Message-Id: <63opf8.905.ln@usenet-autoren.de>
Kelvin <k2_1999@hotmail.com> schrob:
> I thought that was the problem of the flock!
> I've already put it in, but little confuse, can any help to solve?
> Here is the code about read and write :
open (WriteResult, ">vote.dat") or die $!;
You should test for success here, especially if using flock().
If the file can't be created and you don't give 'or die' the
flock will fail, in the loop I made below (which is neccesary
on some systems) waisting 20 seconds.
> flock (WriteResult, 2);
You don't test the result of flock, it may have failed.
Do something like
sleep 1 until( flock WriteResult, LOCK_EX );
And even more better:
my $i == 0;
until( flock WriteResult, LOCK_EX )
{
$i++;
die "flock has timed out, quitting." if( $i == 20 );
sleep 1;
}
And yes, don't use numbers for locking mode, they are system dependent.
Rather use the variables from Fcntl::flock. You can import them into
your namespace with the use command like perldoc -f flock says:
use Fcntl qw(:flock);
HTH
Christian
P.S.:
Newsgroup list stripped down because of error in the upstream server.
------------------------------
Date: Mon, 15 May 2000 17:07:27 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: File Upload and Multiple selection drop downs???
Message-Id: <Pine.GSO.4.10.10005151703450.25459-100000@user2.teleport.com>
On Mon, 15 May 2000, Dan wrote:
> I am having trouble creating a script which is capable of uploading a
> file and returning all the selected items from a multiple selection
> drop down menu.
Perl doesn't have menus, any more than an airplane has vacations. Are you
trying to get a browser to behave differently? Perhaps you want to search
for the docs, FAQs, and newsgroups about web browsers and how to write
programs that talk to them. Reading comp.infosystems.www.authoring.cgi may
be a good start. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 23:11:38 +0200
From: Christian Winter <thepoet1@arcormail.de>
Subject: Re: Forms with Perl
Message-Id: <a6ppf8.905.ln@usenet-autoren.de>
Ian <duxbury@kentmere23.freeserve.co.uk> schrob:
> When I try to run this script on my windows ActivePerl I get this prompt "
> (offline mode: enter name=value pairs on standard input)". Can anyone tell
> me what it means, I just trying to learn how to send data to forms.Thanks.
Yes, and this is what your script expects. You may now enter
as meny lines of name=value pairs as you like, e.g.
button1=yes
button2=yes
text1='this is a test'
[CTRL+D]
But you can also specify this values on the command line of
the script,
perl myscript.cgi button1=yes button2=yes text1='this is a test'
should spare you input prompt (i'm not quite sure of windows
likes the single ticks, yous double quotes if you get an error).
HTH
Christian
------------------------------
Date: Mon, 15 May 2000 23:00:06 +0200
From: Christian Winter <thepoet1@arcormail.de>
Subject: Re: How to COPY a website
Message-Id: <mgopf8.905.ln@usenet-autoren.de>
Keith Smith <ksmith@firesnacks.com> schrob:
> Are there any good scripts out there for retrieving all the files found at a
> website? Essentially, I would like to point this tool at a URL and have it
> decend all the local links and retrieve all the content associated with
> static html links.
Maybe a look at
http://info.webcrawler.com/mak/projects/robots/robots.html
can help you (haven't been there yet, just taken from
perldoc LWP::RobotUA).
HTH
Christian
------------------------------
Date: Mon, 15 May 2000 22:05:07 GMT
From: miadel@step.polymtl.ca ()
Subject: Re: How to test perl CGI scripts on my computer first?
Message-Id: <nw_T4.657$to2.48389@carnaval.risq.qc.ca>
Dave Cross wrote:
: On Sun, 30 Apr 2000 07:05:15 -0400, "Ryan & Treena Carrier"
: <ryanc@nci1.net> wrote:
: >I'm trying to figure out how to set my computer up so I can write some CGI
: >scripts in Perl and test them on my computer before posting them to my
: >internet web server.
: >
: >I've tried setting up Personal Web Server (I'm running Windows 98) but my
: >computer locks up when trying to start the Transaction Server, so I had to
: >uninstall it.
Hello!
I had the same problem last week. To transform your machine into a server,
simply download the software OmniHTTPd. It is only 2 Megs, works on
Windows 95/98 and NT, is relatively simple to configure and allows perl
scripts. You can find it on tucows (www.tucows.com, search on omnihttpd).
There is AnalogX SimpleServer which is tiny, about 200k. But despite what
is written on tucows, it will only run compiled CGI´s, not perl ones.
Hope this helps!
------------------------------
Date: Mon, 15 May 2000 17:13:44 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Initializing variables
Message-Id: <Pine.GSO.4.10.10005151713130.25459-100000@user2.teleport.com>
On Mon, 15 May 2000 jamalone@earthlink.net wrote:
> The problem is that when I fill in the field on the web page and click
> submit, it varies as to what output is displayed. Sometimes it uses
> values that I entered on a previous submit instead of what I just
> submited.
Sounds like sticky fields from the CGI module. Is that it? Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 22:10:48 GMT
From: yahya95@hotmail.com
Subject: LWP POST and send cookies
Message-Id: <8fpskt$8aj$1@nnrp1.deja.com>
I am attempting to interact with remote cgi-script from a cgi script.
Posting parameters to the remote cgi script is fine using LWP. But what
need to do is also submit a cookie along with that LWP POST.
Effectively I am creating a dedicated browser which only browsers one
page and sends a cookie to the server.
Can anyone help with the cookie sending part?
Thanks
Ian Nisbet
ian@nisbet.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 15 May 2000 20:58:02 -0400
From: Scott Gifford <sgifford@tir.com>
Subject: Odd fork() problem
Message-Id: <m3itwf8g6d.fsf@sgifford.tir.com>
I'm trying to speed up a process by reading in chunks of input,
forking off a process to process each chunk and write the result into
a temp file, then joining all of these files together at the end.
The slow part is processing the file chunks, so this speeds things up
noticably.
I'm having a problem, however, which I've been completely unable to
track down. When I'm processing this file, the same part of the file
appears to sometimes get read more than once by the <STDIN> operator.
I'm creating the output files entirely within the child process, so
there shouldn't be any buffering problems on that end of thing.
STDIN is buffered, but I don't see how that would make a difference.
When I count input bytes, I get a number that matches the size of the
file it's creating, which implies that the problem is happening on
input, not output.
I've reduced my program down to demonstrate the problem. If I run the
included program with STDIN redirected from some pretty large file, it
will create a bunch of tempfiles called "/tmp/testfile.*" and one big
file called "/tmp/bigfile". bigfile should be identical to the input
file, but at least for me, it isn't:
admin% ls -l testinput
-rw-r--r-- 2 sgifford other 67554571 May 9 01:52 testinput
admin% ./test <testinput
admin% ls -l /tmp/bigfile
-rw-r--r-- 1 sgifford other 67721434 May 16 00:51 /tmp/bigfile
This is on a Solaris 2.6 system:
SunOS admin.XXXXXXX.com 5.6 Generic_105181-16 sun4u sparc SUNW,Ultra-2
Anybody have any good ideas?
Thanks,
-----Scott.
#!/usr/local/bin/perl
# NOTICE -- AS IS, THIS PROGRAM REMOVES /tmp/testfile.* AND /tmp/bigfile.
# IF YOU HAVE ANYTHING THAT MIGHT BE NAMED THAT, DON'T RUN IT!
# First clean up our temp files, for a nice fresh start
chdir("/tmp");
system("rm -f testfile.* bigfile");
while (<STDIN>)
{
$l++;
$p .= $_;
if ( ($l % 50000) == 0 )
{
# Every 50,000'th line, process the current output.
$fn = sprintf "%s.%03d", "testfile", $filenum;
push(@tempfiles, $fn);
printit($fn, \$p);
$p="";
}
}
$fn = sprintf "%s.%03d", "testfile", $filenum;
push(@tempfiles, $fn);
printit($fn, \$p);
$p = "";
# Let the last process finish.
wait();
open(OUT, "> bigfile")
or die "Couldn't open 'bigfile' for write: $!\n";
foreach $file (@tempfiles)
{
open(F, "< $file")
or die "Couldn't open '$file' for read: $!\n";
while (<F>)
{
print OUT;
}
close(F)
or die "Couldn't close '$file' from read: $!\n";
}
close(OUT)
or die "Couldn't close 'bigfile' from write: $!\n";
sub printit
{
my($fn, $pS)=@_;
wait();
$filenum++;
if (fork() == 0)
{
close(STDIN);
open(STDIN,"< /dev/null");
open(F,"> $fn")
or die "Couldn't open '$fn': $!\n";
print F $$pS;
close(F);
exit(0);
}
}
------------------------------
Date: Mon, 15 May 2000 15:41:09 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: PERL on CDROM
Message-Id: <Pine.GSO.4.10.10005151527250.25459-100000@user2.teleport.com>
On Mon, 15 May 2000, Sam Stone wrote:
> I have a perl program (it makes webpages) and it runs nicely on a
> server . Is there any way possible for me to take that perl program
> and have it run on a CDROM disc?
Your perl binary doesn't know, doesn't care, and would have to go to some
trouble to find out that your program is stored on a CD rather than a hard
disk.
> Ideally, a way where the user can use the CDROM and
> doesn't have to be connected to the Internet.
Your perl binary doesn't know, doesn't care, and would have to go to some
(small) trouble to find out whether it's connected to the Internet or not.
Of course, if your program is expecting to be called by a webserver, it
may be disappointed to find that you're running it from the command line.
Is that your situation?
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 17:01:13 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: perl on OS390
Message-Id: <Pine.GSO.4.10.10005151700410.25459-100000@user2.teleport.com>
On Mon, 15 May 2000, Matteo Palmieri wrote:
> Does anybody know what is the last supported version of perl for OS390
> platform ?
If it's not 5.6.0, it should be. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 May 2000 22:39:41 +0200
From: Christian Winter <thepoet1@arcormail.de>
Subject: Re: perl script to manage sendmail?
Message-Id: <danpf8.905.ln@usenet-autoren.de>
steve <schan_ca@geocities.com> schrob:
> Any idea on how to manage sendmail via a perl script?
> I need to manage email accounts, aliases and redirect email.
> Are there Perl modules for this? If not what steps do I need
> to know to code this myself?
Maybe you could take a great bunch of info out of
"install-sendmail", which is available at www.freshmeat.net
This is a installation- and basic-configuration-script for
sendmail+fetchmail, there are different file locations on
different sendmail-distributions already coded inside, as
well as all neccessare arguments to create configuration
files for dialup-machines, LAN mail servers etc.
HTH
Christian
------------------------------
Date: Mon, 15 May 2000 17:12:21 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl vs ActivePerl
Message-Id: <Pine.GSO.4.10.10005151710030.25459-100000@user2.teleport.com>
On Mon, 15 May 2000, Saddek Rehal wrote:
> Can someone tell me the difference between Perl 5. 03 and perl 5.6.
If the various 'perldelta' manpages aren't informative enough, you'll
probably need to look at the patches. :-)
> The problem is that I get only the second print statement that
> "$dateout" , when I run perl 5.6
Try stepping through your code in the debugger. If you're certain that 5.6
isn't doing what it should, make a small, self-contained example program
which demonstrates the possible bug. Thanks!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
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 3055
**************************************