[15609] in Perl-Users-Digest
Perl-Users Digest, Issue: 3022 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 11 21:08:42 2000
Date: Thu, 11 May 2000 18:05:11 -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: <958093511-v9-i3022@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 11 May 2000 Volume: 9 Number: 3022
Today's topics:
Activestate Perl 5.6 crashes (Bart Lateur)
Re: Activestate Perl 5.6 crashes <bwalton@rochester.rr.com>
Re: associating a filename with a FileHandle (Bart Lateur)
Re: associating a filename with a FileHandle <lr@hpl.hp.com>
Re: call by reference subroutine!! <muravi@hotmail.com>
Re: call by reference subroutine!! <lr@hpl.hp.com>
Re: call by reference subroutine!! (Bart Lateur)
CGI::Carp - Non fatal errors (Jerome O'Neil)
Re: Difficuly psting to a web site. Maybe a Port issue! <lr@hpl.hp.com>
Re: directory contents showing up ?!? <danielxx@bart.nl>
Re: Help needed with Perl and Netscape Fasttrack server <lr@hpl.hp.com>
How to use system and "cd" command? jgtrujillo@my-deja.com
Re: How to use system and "cd" command? mcnuttj@missouri.edu
Re: How to use system and "cd" command? (Bart Lateur)
Re: How to use system and "cd" command? <matt.stoker@motorola.com>
Re: HOW: I want to set the time... <lr@hpl.hp.com>
Re: HOW: I want to set the time... <jeff@vpservices.com>
Re: HOW: I want to set the time... <lr@hpl.hp.com>
Ideas on how to automatically fill out and send forms <gnielson@charlotte.infi.net>
Re: Ideas on how to automatically fill out and send for <tina@streetmail.com>
Re: Ideas on how to automatically fill out and send for <makarand_kulkarni@My-Deja.com>
Re: Ideas on how to automatically fill out and send for <Tbone@pimpdaddy.com>
Perl 5.6 and XS <bkennedy@hmsonline.com>
Polly a stupid question (Darren)
Re: Polly a stupid question <baughj@rpi.edu>
Regex Question (hopefully, an educated guess) mcnuttj@missouri.edu
Re: Regular expression ? <matt.stoker@motorola.com>
Re: regx question (Bart Lateur)
Re: regx question (Randal L. Schwartz)
Re: shooting yourself in the foot ... (Andrews)
Re: Still a double insert with DBI <schaefer@zanshin.com>
Re: string and numeric data handling <lr@hpl.hp.com>
Re: tie 'MLDBM' from a CGI script not working -- any cl <baughj@rpi.edu>
Win32::OLE and OUT parameters ()
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 May 2000 00:10:15 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Activestate Perl 5.6 crashes
Message-Id: <391f496e.5719779@news.skynet.be>
I've downloaded the newest and greatest ActiveState Perl 5.6 for Win32.
I also got the PPM update, and the newer XML::Parser module.
What I do is install Perl 5.6. Then I apply the PPM patch. I test it:
everything works. Perl looks to behave pretty normally.
Finally, I decompress the new XML::Parser package ZIP (2.28), as per the
docs (the installer uses XML::Parser so that won't do), and update that
PPM.XML file, as per the docs. Remember, this is on a new and pretty
clean install.
Now, whenever I try to do ANYTHING with XML::Parser, I get an "Illegal
opcode" error in Windows. For example, starting up PPM.BAT: kaboom.
Doing
perl -MXML::Parser -e "print $XML::Parser::VERSION"
same thing. Kaboom.
Now, I saved the old XML tree (2.27). I use that to overwrite the 2.28
tree again, but to no avail. Perl + XML::Parser keeps crashing. Er... I
must have forgotten to save and restore something.
I can't believe nobody else is having this problem?
BTW this is on Win98.
p.s. Why do WE, the users, have to download the package, and the fix,
and the parser update, and apply the patch, while the whole thing is at
most a few weeks old?
--
Bart.
------------------------------
Date: Fri, 12 May 2000 00:42:28 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Activestate Perl 5.6 crashes
Message-Id: <391B5283.B0165B98@rochester.rr.com>
Bart Lateur wrote:
>
> I've downloaded the newest and greatest ActiveState Perl 5.6 for Win32.
> I also got the PPM update, and the newer XML::Parser module.
>
> What I do is install Perl 5.6. Then I apply the PPM patch. I test it:
> everything works. Perl looks to behave pretty normally.
>
> Finally, I decompress the new XML::Parser package ZIP (2.28), as per the
I think you will find that the ZIP file for XML::Parser is for Perl
version 5.005_03, and is not advertised or intended to work with Perl
5.6 . XML::Parser version 2.27 seems to work well with Perl 5.6, but
apparently the newer version for 2.28 isn't ready yet. If you wanted,
maybe you could get the source from CPAN and compile it for 5.6, making
whatever patches are required.
> docs (the installer uses XML::Parser so that won't do), and update that
> PPM.XML file, as per the docs. Remember, this is on a new and pretty
> clean install.
>
> Now, whenever I try to do ANYTHING with XML::Parser, I get an "Illegal
> opcode" error in Windows. For example, starting up PPM.BAT: kaboom.
> Doing
> perl -MXML::Parser -e "print $XML::Parser::VERSION"
>
> same thing. Kaboom.
>
> Now, I saved the old XML tree (2.27). I use that to overwrite the 2.28
> tree again, but to no avail. Perl + XML::Parser keeps crashing. Er... I
> must have forgotten to save and restore something.
>
> I can't believe nobody else is having this problem?
>
> BTW this is on Win98.
>
> p.s. Why do WE, the users, have to download the package, and the fix,
> and the parser update, and apply the patch, while the whole thing is at
> most a few weeks old?
You don't have to. You can choose not to download, etc.
>
> --
> Bart.
--
Bob Walton
------------------------------
Date: Thu, 11 May 2000 23:08:57 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: associating a filename with a FileHandle
Message-Id: <391b3a4c.1846413@news.skynet.be>
Donald Lancon wrote:
>Anyway, I guess the best solution is just to bite the bullet and keep
>the filename(s) in a global variable of some sort (as Tom P.
>suggested). Dammit. ;-)
If you use a custom function to open the file for you, you might
eventually do that transparantly.
Er... how?
--
Bart.
------------------------------
Date: Thu, 11 May 2000 17:40:45 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: associating a filename with a FileHandle
Message-Id: <MPG.1384f2eb4ca79f8b98aa61@nntp.hpl.hp.com>
In article <391b3a4c.1846413@news.skynet.be> on Thu, 11 May 2000
23:08:57 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Donald Lancon wrote:
>
> >Anyway, I guess the best solution is just to bite the bullet and keep
> >the filename(s) in a global variable of some sort (as Tom P.
> >suggested). Dammit. ;-)
>
> If you use a custom function to open the file for you, you might
> eventually do that transparantly.
>
> Er... how?
#!/usr/bin/perl -w
use strict;
my %files = (
\*STDIN, 'stdin',
\*STDOUT, 'stdout',
\*DATA, 'data',
);
print $files{\*DATA}, "\n";
sub Open {
open my $fh, $_[0] or die "Couldn't open '$_[0]'. $!\n";
$files{$fh} = $_[0];
$fh
}
my $fh = Open $0;
print "$files{$fh}\n--------\n\n", <$fh>;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 11 May 2000 22:17:08 GMT
From: "sagil" <muravi@hotmail.com>
Subject: Re: call by reference subroutine!!
Message-Id: <EjGS4.53$3r1.4695@news2.randori.com>
Try this out:
calling a function:
myfunction(\@array,\$scalar,\%hash);
In definition:
myfunction
{
my ($arr_ref,$scalar_ref,$hash_ref) = @_;
#using them: @$arr_ref, $$scalar_ref, %$hash_ref
}
for further details read perl documentation.
<prakash_ojha@my-deja.com> wrote in message
news:8ff720$tcb$1@nnrp1.deja.com...
> I want to write a subroutine that takes parameter by reference just like
> in C, so that I can change the passed argument without returning a
> value of some thing of that sort. can anyone help?
>
> thanks in advance,
> prakash
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
------------------------------
Date: Thu, 11 May 2000 16:27:18 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: call by reference subroutine!!
Message-Id: <MPG.1384e1ad67c7c1098aa5f@nntp.hpl.hp.com>
In article <8ff720$tcb$1@nnrp1.deja.com> on Thu, 11 May 2000 21:00:59
GMT, prakash_ojha@my-deja.com <prakash_ojha@my-deja.com> says...
> I want to write a subroutine that takes parameter by reference just like
> in C, so that I can change the passed argument without returning a
> value of some thing of that sort. can anyone help?
Parameters are passed by *value* in C, by reference in Perl. To pass a
parameter by value, copy it into a lexical variable in the subroutine.
sub foo {
my $var = shift;
or:
my $var = $_[0];
or:
my ($var) = @_;
For more details,
perldoc perlsub
The answers posted by Makarand Kulkarni and by sagil seem to be based on
a misreading of the question, because of your mistake in the first
clause.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 11 May 2000 23:55:33 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: call by reference subroutine!!
Message-Id: <391e4768.5201946@news.skynet.be>
prakash_ojha@my-deja.com wrote:
>I want to write a subroutine that takes parameter by reference just like
>in C, so that I can change the passed argument without returning a
>value of some thing of that sort. can anyone help?
YOU can. Just don't make copies of the parameters passed in @_. Use them
directly.
sub test {
$_[1] = 'Cuckoo!';
}
@ary = ('A' .. 'C');
test(@ary);
print "@ary\n";
p.s. "Just like in C" ain't right. "Just like in (Visual) Basic" would
be more like it, because, it doesn't make a difference in your function
call. It does in C.
--
Bart.
------------------------------
Date: Thu, 11 May 2000 23:26:49 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: CGI::Carp - Non fatal errors
Message-Id: <ZkHS4.19$U43.680@news.uswest.net>
Here is some odd behavior I have found new with the 5.6 release,
and CGI::Carp.
Given the following code:
#!/usr/local/bin/perl -w
use strict;
use CGI qw{-no_debug};
use CGI::Carp qw{fatalsToBrowser};
BEGIN{
for({qw{CGI Foo}){
if(!eval "require $_"){
print qq{$_ is not installed\n};
}else{
print qq{$_ is installed\n};
}
}
}
If I run this under 5.005_03 perl DWIM and outputs:
CGI is installed
Foo is not installed
However, if I run it under 5.6, perl carps about being unable to
find out about Foo:
Can't locate Foo.pm in @INC ...
I'm not sure what the expected behavior is, but I like the
first. I would think that a fatal error shouldn't be reported
unless it realy is a fatal error.
What, or who is broken?
Thnks!
------------------------------
Date: Thu, 11 May 2000 16:19:17 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Difficuly psting to a web site. Maybe a Port issue!!!!!!!!!!
Message-Id: <MPG.1384dfd01b78ca3098aa5d@nntp.hpl.hp.com>
[Please conform to normal human (and Usenet) expectations by putting
your comments after what you are quoting. And quote selectively, and
with proper attribution. I have rearranged below for legibility.]
In article <391b20c2$0$1091@wodc7nh6.news.uu.net> on Thu, 11 May 2000
16:09:06 -0500, Mohammad Khan <mkhan@crosscom.com> says...
> Jeff Zucker wrote...
> > print $res->message;
> >
> >In the place where you had
> >
> > &log("Network Down.");
> >
> >It should print out the response message. If it doesn't then the
> >problem is in your script somewhere, not in the site you are visiting.
>
> I did as you mentioned in this email. Can you or somebody help me point out
> the errors and as I mentioned in my original email, i can post to other web
> sites, only MCI WorldComm has problem.
>
> HTTP::Response=HASH(0x8b7b50)->content
> HTTP::Response=HASH(0x8b7b50)->message
Though you don't show the code, my PSI::ESP module tells me that you are
trying to interpolate a method invocation into a double-quoted string.
It won't work.
print "$res->message\n"; # WRONG!
print $res->message, "\n"; # OK
print $res->message . "\n"; # OK
print "@{[$res->message]}\n"; # OK
print "${\($res->message)}\n"; # OK
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 11 May 2000 22:44:57 GMT
From: "Daniel van den Oord" <danielxx@bart.nl>
Subject: Re: directory contents showing up ?!?
Message-Id: <JJGS4.542$Kk2.11201@Typhoon.bART.nl>
I want to make a CGI script with a custom layout and extra options like
show next 20 or previous and stuff so it should be dynamic !!! not like the
webserver and put it on enable directory browser if standard file isn't
found !!
ItDaniel van den Oord ( Daniel304
RTCL ) ---------------------------------------------------------------------
----------- It's nice to be important, but it's more important to be nice
See there be good bye
bye ------------------------------------------------------------------------
-------- Daniel304rt ResearchTriangle Community Leader
http://www.geocities.com/ResearchTriangle/Forum/5577
"Makarand Kulkarni" <makarand_kulkarni@My-Deja.com> schreef in bericht
news:391B02A6.37FC7CB2@My-Deja.com...
>
>
> Daniel van den Oord wrote:
>
> > I want to make a CGI script that displays the files in a specified
> > directory So I don't have to make a database or a HTML thingy I have
> > to continuously change when a file is changed !! is this possible ???I
> > know some CGI except that.... please helpDaniel van den Oord (
> > Daniel304 RTCL )
>
> Unless the directory in question was not under DOCUMENT_ROOT
> you can let the web server do this task for you by setting
> the Directory indexing ON ( refer to you webserver docs ).
> --
>
------------------------------
Date: Thu, 11 May 2000 16:20:38 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Help needed with Perl and Netscape Fasttrack server!!!!!!!!!!!!!!!1
Message-Id: <MPG.1384e0228a95a7ee98aa5e@nntp.hpl.hp.com>
In article <391b1650$0$1085@wodc7nh6.news.uu.net> on Thu, 11 May 2000
15:24:39 -0500, Mohammad Khan <mkhan@crosscom.com> says...
> We have a customer who is using Netscap Fasttrack server on HPUX and our
> web server software. Now he get's a Internal Server Error when he tries to
> execute these perl scripts. This is netscape web server log file, when he
> executes one of the perl script.
>
> When Message Results selected: [10/May/2000:15:40:05] config: for host
> 162.100.117.29 trying to POST /cgi-bin/logres.pl, handle-processed reports:
> no way to service request for /cgi-bin/logres.pl
>
> The perl script run's fine from the command line. I will appreciate any help
> on this issue.
perlfaq9: "My CGI script runs from the command line but not the browser.
(500 Server Error)"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 11 May 2000 22:49:11 GMT
From: jgtrujillo@my-deja.com
Subject: How to use system and "cd" command?
Message-Id: <8ffdd2$4pt$1@nnrp1.deja.com>
Problem description: I want to update the "modified" time for all files
in a directory (i.e. /home/usr/data). Why? My SA archives files that
haven't been accessed in > 14 days for some of our directories. After
these files have been archived it is like pulling teeth to get them
from tape.
I have been using this from command line (some users have "trouble"
using this command):
% find . -type f touch {}\;
I want to write a cgi interface that allows the user to specify the
directory and all of the files will be updated.
Problem: when I use the "system" command and try to issue `cd $dir`,
the directory and files that get updated are the ones in the "cgi-bin"
and not the ones in the user specified directory.
question: can "cd" be used with the "system" command in perl? is there
a better way to update the modified time for files in perl?
thanks, gurus!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 11 May 2000 23:39:15 GMT
From: mcnuttj@missouri.edu
Subject: Re: How to use system and "cd" command?
Message-Id: <8ffgb3$n7p$1@dipsy.missouri.edu>
I'm no guru, but here's what I'd do (kludgy, I think):
$dir = (user's specified dir); # However you get this.
$temp = `pwd`;
chop $temp;
$destdir=$temp.$dir;
$outcome = `touch $destdir *`;
That's a particularly tedious and ugly way to do it, but it'll work.
One difference between 'find' and the above way, though, is that with find
you specified that it must be a file, and find works recursively... so
how about this:
$dir = (user's specified dir); # I assume this is 'known' data.
# If $dir is not an absolute path, use something like this:
# @temp = `pwd';
# chop($temp[0]);
# $destdir = $temp[0].'/'.$dir;
# If $dir is absolute:
$destdir = $dir;
@TEMP = `find $destdir -type f ...`;
Keep in mind that I *know* there's a system call in perl that will get you
the current directory. What's above is a kludge. Also, the syntax for
the `find...` is going to be tricky. Using system() might be a better way
to go. Personally, I prefer:
@TEMP = `find $destdir -type f`;
foreach ( @TEMP ) {
chop($_);
$outcome = `touch $_`;
}
--J
jgtrujillo@my-deja.com wrote:
: Problem description: I want to update the "modified" time for all files
: in a directory (i.e. /home/usr/data). Why? My SA archives files that
: haven't been accessed in > 14 days for some of our directories. After
: these files have been archived it is like pulling teeth to get them
: from tape.
: I have been using this from command line (some users have "trouble"
: using this command):
: % find . -type f touch {}\;
: I want to write a cgi interface that allows the user to specify the
: directory and all of the files will be updated.
: Problem: when I use the "system" command and try to issue `cd $dir`,
: the directory and files that get updated are the ones in the "cgi-bin"
: and not the ones in the user specified directory.
: question: can "cd" be used with the "system" command in perl? is there
: a better way to update the modified time for files in perl?
: thanks, gurus!
: Sent via Deja.com http://www.deja.com/
: Before you buy.
------------------------------
Date: Fri, 12 May 2000 00:13:57 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How to use system and "cd" command?
Message-Id: <39214c2a.6420622@news.skynet.be>
jgtrujillo@my-deja.com wrote:
>Subject: How to use system and "cd" command?
Why? What's wrong with the built-in chdir()?
To answer your question: system "cd $dir" *does* work, but only in the
environment of the child process. When this finishes, the changes are
gone. The next child processes will inherit the parent's environment
(perl), and that hasn't changed.
Use the builtin.
--
Bart.
------------------------------
Date: Thu, 11 May 2000 17:18:58 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: How to use system and "cd" command?
Message-Id: <391B4DF2.915BB666@motorola.com>
I'm not a Unix guru, so my explanation may be a little off, but as I
understand it your problem is called "Lamarckian Heritability".
Basically, what this means is that when you use "system" it launches a
child process. The cd command changes the directory of this child
process, but doesn't change the directory of the parent (your perl
script). When the cd command is completed, the child process dies and
the parent process (your script) is still in it's original directory.
This is also why if you write a simple shell script that changes the
directory, it will appear to give the same behaviour as you describe.
One solution in your case would be to use the perl command "chdir".
Since this is not launching a child process, it will change the
directory for your perl script and you will get the desired behavior.
Another solution is to not change directories, but as another poster
suggested, to use the full path in your touch command. If so desired,
you can get the user's home directory with:
$home = $ENV{HOME};
on most UNIX systems.
Good Luck!
jgtrujillo@my-deja.com wrote:
>
> Problem description: I want to update the "modified" time for all files
> in a directory (i.e. /home/usr/data). Why? My SA archives files that
> haven't been accessed in > 14 days for some of our directories. After
> these files have been archived it is like pulling teeth to get them
> from tape.
>
> I have been using this from command line (some users have "trouble"
> using this command):
> % find . -type f touch {}\;
>
> I want to write a cgi interface that allows the user to specify the
> directory and all of the files will be updated.
>
> Problem: when I use the "system" command and try to issue `cd $dir`,
> the directory and files that get updated are the ones in the "cgi-bin"
> and not the ones in the user specified directory.
>
> question: can "cd" be used with the "system" command in perl? is there
> a better way to update the modified time for files in perl?
>
> thanks, gurus!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
/------------------------------------------------------------------\
| Matt Stoker | email: matt.stoker@motorola.com |
| Unit Process Modeling | Mail Drop: M360 |
| DigitalDNA(TM) Laboratories| Phone: (480)655-3301 |
| Motorola, SPS | Fax: (480)655-5013 |
| 2200 W Broadway Road | Pager: (888)699-8803 |
| Mesa, AZ 85202 | |
\------------------------------------------------------------------/
------------------------------
Date: Thu, 11 May 2000 15:11:00 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: HOW: I want to set the time...
Message-Id: <MPG.1384cfcbf49238ef98aa5b@nntp.hpl.hp.com>
In article <391ABBEA.28C79811@vpservices.com> on Thu, 11 May 2000
06:55:54 -0700, Jeff Zucker <jeff@vpservices.com> says...
> Larry Rosler wrote:
> > In article <3919D434.D9D4E6F@vpservices.com> on Wed, 10 May 2000
> > 14:27:16 -0700, Jeff Zucker <jeff@vpservices.com> says...
> >
> > ...
> >
> > > use LWP::Simple;
> > > print get( "http://www.google.com/search?q=time server" );
> >
> > The Perl syntax is OK, but the query string isn't OK.
> > print get( "http://www.google.com/search?q=time+server" );
> > or
> > print get( "http://www.google.com/search?q=time%20server" );
>
> All true (and something I even thought of myself before posting) if one
> were talking about a query string in a URL rather than a parameter to a
> method. From the LWP docs:
>
> The B<url> is a string denoting the protocol, server and
> the name of the "document" we want to access. The B<url> might
> also encode various other parameters. ^^^^^
The 'might' there refers to an optional query string, not optional
encoding.
> And from the docs for URI which LWP calls via HTTP::Request:
>
> Characters outside this set are automatically escaped by the URI
> constructor.
>
> So, yes I should have escaped it myself for pedagological purposes, but
> I can be legitimately lazy when I acutally use the module.
You can't have it both ways. If, as you say, the module encodes, then
if you encode first you will get wrong results:
Data You LWP Server
'x y' => 'x%20y' => 'x%2520y' => 'x%20y'
or
'x y' => 'x+y' => 'x%2By' => 'x+y'
So an explanatory note about your unencoded string might have been best,
because my correction of your presumed error was wrong.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 11 May 2000 16:05:06 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: HOW: I want to set the time...
Message-Id: <391B3CA2.C9041190@vpservices.com>
Larry Rosler wrote:
>
> You can't have it both ways. If, as you say, the module encodes, then
> if you encode first you will get wrong results:
>
> Data You LWP Server
>
> 'x y' => 'x%20y' => 'x%2520y' => 'x%20y'
>
> or
>
> 'x y' => 'x+y' => 'x%2By' => 'x+y'
>
> So an explanatory note about your unencoded string might have been best,
> because my correction of your presumed error was wrong.
One would think that that would be so but:
d:\> cat > test.pl
#!perl -w
use strict;
use LWP::Simple;
&test('time server');
&test('time+server');
&test('time%20server');
sub test {
my $str = shift;
my $res = get( "http://www.google.com/search?q=$str" );
print "$str : $1\n" if $res =~ m#A HREF=/search\?q=(time[^&]*)&#;
}
d\> perl test.pl
time server : time+server
time+server : time+server
time%20server : time+server
They got their DWIM working pretty good there.
--
Jeff
------------------------------
Date: Thu, 11 May 2000 17:27:55 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: HOW: I want to set the time...
Message-Id: <MPG.1384efe26b1caa9e98aa60@nntp.hpl.hp.com>
In article <391B3CA2.C9041190@vpservices.com> on Thu, 11 May 2000
16:05:06 -0700, Jeff Zucker <jeff@vpservices.com> says...
...
> d:\> cat > test.pl
> #!perl -w
> use strict;
> use LWP::Simple;
> &test('time server');
> &test('time+server');
> &test('time%20server');
> sub test {
> my $str = shift;
> my $res = get( "http://www.google.com/search?q=$str" );
> print "$str : $1\n" if $res =~ m#A HREF=/search\?q=(time[^&]*)&#;
> }
> d\> perl test.pl
> time server : time+server
> time+server : time+server
> time%20server : time+server
>
> They got their DWIM working pretty good there.
Brrr... That is scary bad.
How do I search for C++, for example?
time C++ foo : time+C+++foo => time C foo
time C\+\+ foo : time+C%5C+%5C++foo => time C\ \ foo
time C%2B%2B foo : time+C%2B%2B+foo => time C++ foo
Weird.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 11 May 2000 19:14:06 -0400
From: Gary Nielson <gnielson@charlotte.infi.net>
Subject: Ideas on how to automatically fill out and send forms
Message-Id: <391B3EBE.BB4D547F@charlotte.infi.net>
At our Web site, the online editors every night have to tediously fill
out forms to submit to update pages on other sites with whom we partner.
This gets old after awhile, particularly when the information is
basically URLs and links that we have on our own static html pages. I am
exploring ways to automatically do this work with perl.
So far, I have written a script that will open an html document and grab
all the urls and links. Now I need to figure out how to put them in the
form and automatically send that form to its destination, using cron.
I've been doing some reading about the URI characters that need to be
encoded, etc. when sending a form with the POST method. I am thinking
that I could call lynx inside a script and send the cgi request with all
of the names/values beginning with "?" and separated by "&" with spaces,
question marks and other characters converted to their Hex equivalents.
Am I on the right track? If I am not on the right track, what are some
other ideas and approaches people have used to accomplish this? Are
there scripts out there that will do this encoding already? Are there
scripts that, when given names and values will format cgi requests for
you?
Any help appreciated. Please email reply as well.
Thank you,
Gary
------------------------------
Date: Thu, 11 May 2000 19:29:27 -0400
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Ideas on how to automatically fill out and send forms
Message-Id: <8fffoa$aqpr6$1@fu-berlin.de>
hi,
Gary Nielson wrote:
> At our Web site, the online editors every night have to tediously fill
> out forms to submit to update pages on other sites with whom we partner.
> This gets old after awhile, particularly when the information is
> basically URLs and links that we have on our own static html pages. I am
> exploring ways to automatically do this work with perl.
take a look at the LWP-modules (I guess LWP::Simple)
to do a POST-request
> I am thinking
> that I could call lynx inside a script and send the cgi request with all
> of the names/values beginning with "?" and separated by "&" with spaces,
> question marks and other characters converted to their Hex equivalents.
well, never came to think of that, but that's not the way you should
do it...
tina
--
--- ICQ #73179850 --- | _ enter the
http://user.berlin.de/~tina.mueller | __| |___ ___ _ _ ___
---- tina's moviedatabase ----| / _` / _ \/ _ \ '_(_-< of
--search & add comments or reviews--| \__,_\___/\___/_| /__/ perception
------------------------------
Date: Thu, 11 May 2000 16:40:06 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Ideas on how to automatically fill out and send forms
Message-Id: <391B44D6.C7EB7955@My-Deja.com>
> Are there
> scripts that, when given names and values will format cgi requests for
> you?
perldoc LWP::UserAgent
perldoc LWP::Simple
perldoc HTTP::Request::Common
--
------------------------------
Date: 12 May 2000 00:20:48 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: Ideas on how to automatically fill out and send forms
Message-Id: <8ffip0$1o6d$1@news.enteract.com>
gnielson@charlotte.infi.net writes:
>encoded, etc. when sending a form with the POST method. I am thinking
>that I could call lynx inside a script and send the cgi request with all
>of the names/values beginning with "?" and separated by "&" with spaces,
>question marks and other characters converted to their Hex equivalents.
Small point: don't send stuff in a query string if the form asked
for a POST message. Chances are it is handled by a CGI, which has
been written to handle both cases, but it may not be the case.
If lynx has a command-line way to post stuff, then it's a valid
way to do the job...
------------------------------
Date: Thu, 11 May 2000 22:50:41 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Perl 5.6 and XS
Message-Id: <5PGS4.185643$Tn4.1463727@news1.rdc2.pa.home.com>
What exactly has changed in version 5.6 that prevents some older modules
from compiling? A lot of modules install cleanly under 5.005 but not under
5.6 (for instance Crypt:::Blowfish uses the defunct sv_undef call). Is
there a way to use these older modules with 5.6? I have a feeling that a
lot of older but useful modules won't be rewritten. Thanks --
--Ben Kennedy
------------------------------
Date: Fri, 12 May 2000 00:19:32 GMT
From: prefer_to_look@newsgroup.com (Darren)
Subject: Polly a stupid question
Message-Id: <391b4cc4.25712168@news.u-net.com>
Hello there, as the subject says, this is probably a dumb question but
here goes.......
Imagine a scenario where a form calls a cgi script that will pipe a
web page back to the browser......how do I stop the browser from using
the path of the script. The problem being that the data I pass back
with the script uses images of the path 'images/x.gif' except when
piped from the cgi script the current dir is /cgi-bin when I actually
want the current dir to be '/'.
Now I'm just at a loss as to what to do (I understand why this is
happening just not how best to fix it).
Thanks for any help.
Darren
------------------------------
Date: Thu, 11 May 2000 20:40:50 -0400
From: justin baugh <baughj@rpi.edu>
Subject: Re: Polly a stupid question
Message-Id: <391B5312.6FA88EE4@rpi.edu>
> Imagine a scenario where a form calls a cgi script that will pipe a
> web page back to the browser......how do I stop the browser from using
> the path of the script. The problem being that the data I pass back
> with the script uses images of the path 'images/x.gif' except when
> piped from the cgi script the current dir is /cgi-bin when I actually
> want the current dir to be '/'.
<img src="/images/x.gif">
~j
--
==================================================
Justin Baugh (baughj@nocannedmeat.rpi.edu)
PGP: http://www.rpi.edu/~baughj/keys.txt
"Evil is easy, and has infinite forms." - Pascal
------------------------------
Date: 11 May 2000 23:14:21 GMT
From: mcnuttj@missouri.edu
Subject: Regex Question (hopefully, an educated guess)
Message-Id: <8ffesd$jqj$1@dipsy.missouri.edu>
The Project: I've got a perl script that goes out and queries a bunch of
network devices using SNMP. There are lots of kludgy things done in this
script, but here's the code I'm worried about:
$mib='system';
@TEMP = snmpwalk($community, $ip, $mib); # snmpwalk is in a sub I wrote
SYSTEM: foreach ( @TEMP ) {
if ( /^sysDescr.+ : (.*)$/ ) {
if ( $1 eq '' ) {
print "System name is NULL.\n";
}
next SYSTEM;
}
if ( /^sysLocation.+ : (.*)$/ ) {
.
.
.
}
}
This is the basic idea. The 'snmpwalk' function is basically a wrapper
for the scotty "snmpwalk" Tcl script, which does the SNMP calls. (One of
these days I'll figure out Socket::SNMP, but not today.) Since this is
*very* slow, I try to make the queries large, so I can get as much data
for parsing all at once in the @TEMP array.
So here's the question: Is that regular expression a good one? More
specifically:
1) How do the ^ and $ requirements affect the speed? Faster or slower?
2) How do the specific strings affect the speed? If the code around it
is done properly, I could, for example, use / : (.*)$/ and it would work
just fine, but is that slower than using the far-more-specific regex I
have above?
3) If won't work in all cases, but someone mentioned before that 'split'
might work better in a case like this. I could split on /\s+:\s+/, since
the colon will never appear on the "left" side of the string (it might
appear on the "right", but by then, the pattern is already matched). As
long as I don't use s///g, it'll only match once, and I'll be all right,
right?
4) How much do (\w+), (.+), (\s+), (\d+), etc. slow things down? I avoid
the use of things like (.*) (the code shown above is an exception), but
what about the + quantifier and the parentheses?
Speed is the objective here. Ideas and comments welcome. Flames can be
sent to /dev/null (or, NUL:, for Wintendo users). Consider the various
'perlfaq' man pages thumbed through, but not *combed* through. :-)
Thanks!
--J
------------------------------
Date: Thu, 11 May 2000 17:41:19 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: Regular expression ?
Message-Id: <391B532F.E193C00E@motorola.com>
Jeff Zucker wrote:
>
> tvn007@my-deja.com wrote:
> >
> > sorry, the input file is more complicate so I do not think I can use
> > split.
> >
> > The actual input file would be something like this:
> > abc : 0_0 2.02 A
> > 305 : 0_0 2.01 A
> > 306 : 0_0 1.80 AR
> > 305 : 0_0 2.50 AR
> >
>
> That would work exactly the same as the other with the split. The only
> thing that would break the split would be if there were a different
> number of non-whitespace elements before the one you want to catch.
>
> --
> Jeff
Except if I understand, he wouldn't want to get 2.02 when the first
column contains non-numeric values. In which case this would work:
while(<DATA>) {
my @ary = split " "; # use " " instead of /s+/ to
# ignore leading white space
print "$ary[3]\n" unless ($ary[0]=~/\D/);
}
>
> > > 305 : 0_0 2.01 A
> > > > 306 : 0_0 1.80 AR
> > > > 305 : 0_0 2.50 AR
> >
> > In article <391B12FB.F3A649CA@vpservices.com>,
> > Jeff Zucker <jeff@vpservices.com> wrote:
> > > tvn007@my-deja.com wrote:
> > > >
> > > > Hi,
> > > >
> > > > Could someone please help me with the following pattern matching ?
> > > >
> > > > Here is the data:
> > > >
> > > > 305 : 0_0 2.01 A
> > > > 306 : 0_0 1.80 AR
> > > > 305 : 0_0 2.50 AR
> > > >
> > > > I would like to extract number 2.01, 1.80 and 2.50
> > >
> > > I'd use split() rather than a regex to do that.
> > >
> > > while(<DATA>) {
> > > my @ary = split /\s+/;
> > > print "$ary[3]\n";
> > > }
> > >
> > > --
> > > Jeff
> > >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
--
/------------------------------------------------------------------\
| Matt Stoker | email: matt.stoker@motorola.com |
| Unit Process Modeling | Mail Drop: M360 |
| DigitalDNA(TM) Laboratories| Phone: (480)655-3301 |
| Motorola, SPS | Fax: (480)655-5013 |
| 2200 W Broadway Road | Pager: (888)699-8803 |
| Mesa, AZ 85202 | |
\------------------------------------------------------------------/
------------------------------
Date: Thu, 11 May 2000 23:50:31 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: regx question
Message-Id: <391d3e0b.2805239@news.skynet.be>
dc wrote:
>Can anyone provide a better perl regular expression for matching on
>any word that has all 5 vowels in any order?
>
>/(?=.*a)(?=.*e)(?=.*i)(?=.*o).*u/
>
>Is there a more efficient way to do this? Is this grossly
>inefficient? Is there a way to do this without using lookahead?
I don't know about "grossly inefficient", except when it fails: it will
do a LOT of unnecessary backtracking. If it doesn't match at the first
character position, it will try again at the second character position,
etc., which all can only succeed if the very first test matched, and
have even less chance of success than the previous (fewer characters =
few chance of success).
At least, anchoring the regex will improve speed a lot in the case of
failure, because it prevents just that backtracking.
/^(?=.*a)(?=.*e)(?=.*i)(?=.*o).*u/
I don't know if this is the best you can do. I've read of other trick to
prevent backtracking, such as the (?>...) construct, but I don't think
that it is applicable here.
Benchmark comparisons should be made to:
/a/ && /e/ && /i/ && /o/ && /u/
which must be close to the optimal solution, except that it's five
regexes, not one.
Now, since you're in this for the learning: there was a very interesting
thread about this kind of things, in the middle of july last year, under
the subject title 'Why does this regex take "forever"?', initiated by
Russ Allbery. I found it back on Deja(News). Too bad that Deja gives
such crappy URL's, and it may be useless to post it here. I can try.
<http://x26.deja.com/[ST_rn=ps]/viewthread.xp?AN=501200275>
--
Bart.
------------------------------
Date: 11 May 2000 17:08:32 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: regx question
Message-Id: <m1ln1g7hq7.fsf@halfdome.holdit.com>
>>>>> "Bart" == Bart Lateur <bart.lateur@skynet.be> writes:
Bart> At least, anchoring the regex will improve speed a lot in the case of
Bart> failure, because it prevents just that backtracking.
Bart> /^(?=.*a)(?=.*e)(?=.*i)(?=.*o).*u/
Bart> I don't know if this is the best you can do. I've read of other trick to
Bart> prevent backtracking, such as the (?>...) construct, but I don't think
Bart> that it is applicable here.
No, the better you can do is to use mini-matches, not maxi-matches:
/^(?=.*?a)(?=.*?e)(?=.*?i)(?=.*?o).*?u/
That way you find the first a, not the last one!
--
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: 11 May 2000 16:07:40 -0700
From: gerg@ncal.verio.com (Andrews)
Subject: Re: shooting yourself in the foot ...
Message-Id: <8ffefs$2a8$1@ncal.verio.com>
tadmc@metronet.com (Tad McClellan) writes:
>
>Make a trigger pulling motion, and Perl will:
>
> autovivify a gun for you
>
> initialize it with bullets
>
> fire a bullet
>
> move your foot so as to coincide with the bullet's trajectory
>
> say "Ouch!" for you
>
And Tom Christiansen says, "you should've used strict and -w !"
-Greg
--
::::::::::::::::::: Greg Andrews gerg@wco.com :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
------------------------------
Date: Thu, 11 May 2000 15:27:40 -0700
From: Bart Schaefer <schaefer@zanshin.com>
Subject: Re: Still a double insert with DBI
Message-Id: <Pine.LNX.4.20.0005111514040.11665-100000@aztec.zanshin.com>
On Thu, 11 May 2000, Eric van Huijgevoort wrote:
> Thanks for your replay,
>
> Unfortunately the double insert appears also without $max_ordernumber.
I experienced a problem with the mysql client library implementation that
could cause the same SQL statement to be transmitted twice from the client
to the server in some circumstances. Comparing a TCP trace to a C code
debugger walkthrough showed that two transmissions were occurring for one
mysql_real_query() call. I never found out why; we ended up adding an
extra bit of SQL to delete the duplicates after the insertions, and then
later switched to another DB engine and never investigated any further.
------------------------------
Date: Thu, 11 May 2000 16:06:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: string and numeric data handling
Message-Id: <MPG.1384dcbd9d469cf098aa5c@nntp.hpl.hp.com>
In article <8ff1gd$n1g$1@nnrp1.deja.com> on Thu, 11 May 2000 19:26:25
GMT, nfin8axs@hotmail.com <nfin8axs@hotmail.com> says...
> I am having some difficulty with the concept of string handling in PERL.
perlfaq1: "What's the difference between ``perl'' and ``Perl''?"
> Is there a construct in PERL that does the equivalent of data casting
> in C?
You don't need one.
> I have a string of numbers that I wish to convert to a numeric
> value. Will simple performing a numeric operation on the variable be
> enough? (eg : $data = $data + 0;) or is there a more intelligent method?
Perl will treat a scalar variable as a number in a numeric context
(i.e., when a number is expected) or as a string in a string context
(i.e., when a string is expected). This automatic type conversion is a
neat feature.
See the beginning of the section 'Scalar Values' in perldata.
> Any suggestions would be greatly appreciated, as I am getting accustomed
> to the PERL programming syntax and environment.
Welcome to the club. 'Have the appropriate amount of fun!' (Larry Wall)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 11 May 2000 18:23:09 -0400
From: justin baugh <baughj@rpi.edu>
Subject: Re: tie 'MLDBM' from a CGI script not working -- any clues?!!
Message-Id: <391B32CD.75916483@rpi.edu>
> Here's a partial snippet; the message ($msg) returned is always the
> same: Cannot tie. No such file or directory.
>
> sub write_to_file {
> my %dbdata; my %tempdata;
> my $key; my $last = 0; my $id; my $name;
> tie(%dbdata, 'MLDBM', $dbfile) or $msg = $msg . "Cannot tie. $!
> <p>\n";
This will fail if the database doesn't exist. Also, is $dbfile a
global?
If you want to create a database when one isn't found, use this:
tie %dbdata, 'MLDBM', $dbfile, O_RDWR | O_CREAT or die
"Cannot tie to database $dbfile: $!";
(btw you should use die there instead of $msg = $msg)
The O_RDWR and O_CREAT are flags (man open will tell you more about
these). O_CREAT tells tie to create the database if it doesn't exist,
and O_RDWR indicates that the database can be read from and written
to.
Hope this helps,
~j
--
==================================================
Justin Baugh (baughj@nocannedmeat.rpi.edu)
PGP: http://www.rpi.edu/~baughj/keys.txt
"Evil is easy, and has infinite forms." - Pascal
------------------------------
Date: 12 May 2000 00:58:16 GMT
From: kmead@socrates.berkeley.edu ()
Subject: Win32::OLE and OUT parameters
Message-Id: <8ffkv8$45o$1@agate.berkeley.edu>
Hi,
I'm using Win32::OLE to call an ActiveX object. In the
simplest case, the object's method has one parameter which
is declared in IDL to be an OUT parameter (not OUT, RETVAL)
of type long.
However, I can't seem to get that value from Perl.
I've tried both:
$obj->MyMethod($num);
$obj->MyMethod(\$num);
Thanks
Keith
------------------------------
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 3022
**************************************