[17500] in Perl-Users-Digest
Perl-Users Digest, Issue: 4920 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 18 21:05:34 2000
Date: Sat, 18 Nov 2000 18:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974599510-v9-i4920@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 18 Nov 2000 Volume: 9 Number: 4920
Today's topics:
Re: @Arrays as Parameters (Tom Hoffmann)
Re: @Arrays as Parameters <uri@sysarch.com>
apache perl module? EOH? <junk@beetfoundation.com>
Re: apache perl module? EOH? (Gwyn Judd)
Re: apache perl module? EOH? <flavell@mail.cern.ch>
Re: apache perl module? EOH? <brian+usenet@smithrenaud.com>
Re: Beginners blues. <johngros@Spam.bigpond.net.au>
Re: Beginners blues. <johngros@Spam.bigpond.net.au>
Re: Beginners blues. <johngros@Spam.bigpond.net.au>
Re: Beginners blues. (Tad McClellan)
Calling Javascript from Perl - not working! fhinchey@my-deja.com
Re: Calling Javascript from Perl - not working! <kstep@pepsdesign.com>
Re: hash printout (Tad McClellan)
Re: I am sorry for posting this so many times! <uri@sysarch.com>
Re: I am sorry for posting this so many times! (Gwyn Judd)
Re: multidimensional array help (Logan Shaw)
Re: multidimensional array help (Tad McClellan)
Perl beginner <captmarvil@rcn.com>
perl man pages (Jie Gao)
Re: perl man pages <brian+usenet@smithrenaud.com>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Re: simple question: can Perl do this? (talking to a pe (Anno Siegel)
Re: simple question: can Perl do this? (talking to a pe <kstep@pepsdesign.com>
Re: simple question: can Perl do this? (talking to a pe (Tad McClellan)
Re: simple question: can Perl do this? (talking to a pe <kstep@pepsdesign.com>
Re: views and/or cursors with DBD::mysql ?? <kstep@pepsdesign.com>
Re: views and/or cursors with DBD::mysql ?? <stevie_d38nospam@hotmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 18 Nov 2000 23:32:49 GMT
From: tom.hoffmann@worldnet.att.net (Tom Hoffmann)
Subject: Re: @Arrays as Parameters
Message-Id: <slrn91e4ct.lp.tom.hoffmann@localhost.localdomain>
On Thu, 19 Oct 2000 14:50:38 +0100, Stuart MacCallum wrote:
>Hi.
>
> I'm relatively still new to Perl, and have a small problem with the eval
>function. I'm unsure if what I'm asking is feasible, but I've attempted to
>find the answer in the Perl documentation and the web and had no success.
>
>What I want to do is call a perl function named $params[1], and pass the
>array @PIDVALS to it.
>
>eval("$params[1](@PIDVALS2)");
>
> I have changed the array separator ($") to "," so that each item in the
>array would be a separate parameter, this does not work.
>
>If $params[1] = "IDCheck" the following function would be called:
>
> sub IDCheck{
> my @values = @_;
>
> print "Array 1 : $values[0]\n";
> }
>
>If anybody knows how I can pass the array, any help would be most welcome.
I am new to Perl myself, but have writen subroutines that "pass" an
array. I did this by using a symbolic reference to the array as in:
$ptr1 = "arrray" # "array" is the name of the @array
then just passed the reference as in:
some_subroutine ($ptr1)
In the subroutine, $_[0] is the passed reference to the array. Using it
as in:
$_[0]->[1] = "some value"
changes the value of $array[1]. I am sure there are other ways to do
this, but this works for me. BTW, in your code you have the statement:
my @values = @_;
In perl, this kind of assignment of arguments (to local variables)
turns them into "pass by value". This is not what you want. You want to
preserve the array argument as an address, so do not assign it to a
local variable within the subroutine.
Hope this helps.
------------------------------
Date: Sun, 19 Nov 2000 00:09:41 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: @Arrays as Parameters
Message-Id: <x7u294esaj.fsf@home.sysarch.com>
>>>>> "TH" == Tom Hoffmann <tom.hoffmann@worldnet.att.net> writes:
TH> I am new to Perl myself, but have writen subroutines that "pass" an
TH> array. I did this by using a symbolic reference to the array as in:
^^^^^^^^^^^^^^^^^^
that is EVIL and should never be done by someone claiming to be new to
perl. there are many reasons why and if you search deja you can find
them. you should be using proper perl references and never symbolic.
TH> Hope this helps.
it didn't. your post just passed along a very bad way of doing
something. if you use strict (which you should) symrefs won't even be
allowed.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 18 Nov 2000 16:09:37 -0700
From: "Jopa" <junk@beetfoundation.com>
Subject: apache perl module? EOH?
Message-Id: <T4ER5.1876$u47.429880@news.uswest.net>
Hey, does anyone know if you need an apache module to use End of html blocks
print <<EOH;
Html content inhere
EOH
I have apache and perl running, but it seems to reject these these.
TIA,
Jopa
~~~~`
------------------------------
Date: Sat, 18 Nov 2000 23:50:33 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: apache perl module? EOH?
Message-Id: <slrn91e5e7.jm5.tjla@thislove.dyndns.org>
I was shocked! How could Jopa <junk@beetfoundation.com>
say such a terrible thing:
>Hey, does anyone know if you need an apache module to use End of html blocks
>
> print <<EOH;
>
> Html content inhere
>
> EOH
>
>I have apache and perl running, but it seems to reject these these.
This sytax has nothing to do with Apache or any Apache module it is a
pure Perl construct. The correct syntax is like this:
print <<END_OF_STRING;
some stuff here
END_OF_STRING
The end marker can be any single word you like (by convention in upper
case). It has to start right at the very left hand edge of the line it
is on and there cannot be anything else on the line. Also the "print
<<END;" cannot have any white space between "END" and the "<<".
As an aside, you seem to be acting under the delusion that Perl is only
used for creating CGI scripts. This is a complete fallacy.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
If you don't do the things that are not worth doing, who will?
------------------------------
Date: Sun, 19 Nov 2000 00:49:11 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: apache perl module? EOH?
Message-Id: <Pine.GHP.4.21.0011190046490.25705-100000@hpplus03.cern.ch>
On Sat, 18 Nov 2000, Jopa wrote:
> Hey, does anyone know if you need an apache module to use End of html blocks
Why have you posted the same article, without comment, in more than
one group separately? This is called "multiposting" and is
considered to be a Bad Thing. Scorefile adjusted.
> print <<EOH;
>
> Html content inhere
>
> EOH
RTFM. terminating string has to be at left margin.
--
3/4 meiner Kunden sagt von sich, dass sie keinen Wert auf Animationen, bunte
Bilder und Effekte legt. Und die gleichen 3/4 sagen mir, dass ich sowas
machen soll, da alle ihre Kunden das wollten. - Steffi Abel
------------------------------
Date: Sat, 18 Nov 2000 20:51:31 -0500
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: apache perl module? EOH?
Message-Id: <brian+usenet-F8AE9F.20513118112000@news.panix.com>
In article <T4ER5.1876$u47.429880@news.uswest.net>, "Jopa"
<junk@beetfoundation.com> wrote:
> Hey, does anyone know if you need an apache module to use End of html blocks
>
> print <<EOH;
>
> Html content inhere
>
> EOH
>
> I have apache and perl running, but it seems to reject these these.
you don't need anything special to use here documents. perhaps
there is a different error, although it is hard to tell since
you didn't include any code or the error message.
--
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 19 Nov 2000 00:26:12 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Beginners blues.
Message-Id: <E6FR5.12532$tU2.106218@news-server.bigpond.net.au>
I was using a cut down path there in the scriupt it is still the full pat. I
only get can't open file file does not exist.
------------------------------
Date: Sun, 19 Nov 2000 00:33:01 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Beginners blues.
Message-Id: <1dFR5.12539$tU2.106236@news-server.bigpond.net.au>
#!E:/Millenium Programs/perl/bin/Perl -w
use strict;
my($pwd)= my($time);
open BOGUS,"+>>C:\\Progra~1\\G6FTP\\ftpdat~1\\johngros\@bigpond.net.au.txt"
or die "Cannot open file: $!";
close BOGUS;
Like I said I tried this script with the three variations.
Error message verbatim: Cannot open file: No such file or directory at
john.pl line 4.
PS don't forget to expand the message because the path is all one line.
------------------------------
Date: Sun, 19 Nov 2000 01:16:06 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Beginners blues.
Message-Id: <qRFR5.12581$tU2.105586@news-server.bigpond.net.au>
Egg on my face!
I cracked the file does not exist prob. I used the incorrect path, misspelt
one of the directories.
Yet it does not work as I now get Use of uninitialized value in
concatenation (.) at john.pl line 5.
line 5 being : print BOGUS "$pwd+\n";
close BOGUS; getting pushed out to line 6.
------------------------------
Date: Sat, 18 Nov 2000 19:12:43 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Beginners blues.
Message-Id: <slrn91e6nr.15q.tadmc@magna.metronet.com>
On Sun, 19 Nov 2000 00:26:12 GMT, John Boy Walton
<johngros@Spam.bigpond.net.au> wrote:
>I was using a cut down path there in the scriupt it is still the full pat. I
>only get can't open file file does not exist.
Note that the diagnostic message mentions directories as well
as files.
Are are of the intermediate directories in the path there?
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Nov 2000 23:49:39 GMT
From: fhinchey@my-deja.com
Subject: Calling Javascript from Perl - not working!
Message-Id: <8v74ii$a6e$1@nnrp1.deja.com>
I'm having problems calling a javascript function from perl. I have a
multipart form for uploading files to my server. I want to be able to
check if a file of the same name alread exists and pop-up a confirm box
asking if it's okay to overwrite that file. I thought a javascript
would be the way to go, but i can't get it to work. Here's my
javascript...
*********************************************************************
function confirm(filename) {
if (confirm("A logo named " + filename + " already exists. Do you
want to overwrite it?")){
return true;
}
else
{ return false; }
}
*********************************************************************
but more importantly, here's my perl code....
*********************************************************************
$filename = $upload;
$short_filename = $upload;
$short_filename =~ s/.*(\\)//; ##takes out path info
$foo = $short_filename;
$foo =~ tr/\s//; ##takes out whitespace for matching purposes
$dir = "../web/images/logos";
opendir(FOO, $dir) || die "Error: can't open directory $dir: $!";
while ($file = readdir(FOO)) {
if ($file eq $foo){ #file already exists
$result = $window->eval("confirm($file)"); ### IS THIS RIGHT?
if ($result){
push @list, $file;
}
else{next;}
}
else{ ##file doesn't already exist
push @list, $file;
}
}
*********************************************************************
Any ideas what I'm doing wrong? Thanks in advance.
-Frank
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 18 Nov 2000 20:19:44 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: Calling Javascript from Perl - not working!
Message-Id: <8v79od$9be$1@slb6.atl.mindspring.net>
<fhinchey@my-deja.com> wrote in message news:8v74ii$a6e$1@nnrp1.deja.com...
> I'm having problems calling a javascript function from perl. I have a
> multipart form for uploading files to my server. I want to be able to
> check if a file of the same name alread exists and pop-up a confirm box
> asking if it's okay to overwrite that file. I thought a javascript
> would be the way to go, but i can't get it to work. Here's my
> javascript...
Big problem - JavaScript runs on the browser and your upload script runs on
the server. The only way to execute client-side JavaScript from the server
is to serve up a new page with the JS code either inline or triggered by the
onLoad event. For your upload program, you probably don't want to do this.
Why not do something like this:
If a file was uploaded
Parse the file name
If the file exists
Save the file in a temporary location
Return a page asking for confirmation
Else
Save the file
Return a page indicating success
Else if this is a confirmation
If confirmed
Move the temporary file
Return a page indicating success
Else
Delete the temporary file
Return a page indicating deletion
You will need to save some state information such as the file name in a
hidden field so that you know which file to move or delete. You will also
want to add some garbage collection that deletes old temporary files where
the user has uploaded the file and left your site without submitting the
confirmation.
Hopefully this helps,
Kurt Stephens
------------------------------
Date: Sat, 18 Nov 2000 18:07:01 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: hash printout
Message-Id: <slrn91e2sl.uq.tadmc@magna.metronet.com>
On Sat, 18 Nov 2000 08:50:49 -0600, paul simdars <psimdars@lisco.com> wrote:
>Bart Lateur wrote:
>
>> paul simdars wrote:
>> >I have looked thru lots of articles and examples but have not found what
>> >I am
>> >looking for.
You have not looked at the very first place that you should
have looked!
You should not post to the Perl newsgroup without first checking
the Perl FAQ.
Any of these would have found you the answer in 1 second:
perldoc -q sort
perldoc -q hash
perldoc -q value
>> foreach (sort { $hnums{$a} <=> $hnums{$b} } keys %hnums) {
>> print "$hnums{$_} belongs to $_\n";
>> }
>Bart,
>Thanks, that works perfectly. I've tried a number of them and this one
>works.
That is the how the FAQ says to do it. You could have had
the answer in seconds if you had followed standard netiquette.
Please do so in the future. Thanks.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 19 Nov 2000 00:04:36 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: I am sorry for posting this so many times!
Message-Id: <x7wve0esiz.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
>> I apologize for posting this message so many times. I donīt
>> think itīs my fault, it must have something to do with the
>> newsgroup server at my work or outlook.
BL> Thank goodness it didn't happen again with this post. ;-)
but the damned OP is still clogging the net. i see 14 more since noon
today. somebody kill that server!
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sun, 19 Nov 2000 00:59:52 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: I am sorry for posting this so many times!
Message-Id: <slrn91e9g6.kkt.tjla@thislove.dyndns.org>
I was shocked! How could Uri Guttman <uri@sysarch.com>
say such a terrible thing:
>but the damned OP is still clogging the net. i see 14 more since noon
>today. somebody kill that server!
I've been trying. abuse@, news@, newsadmin@ and
postmaster@era.ericsson.se all bounce. This is broken behaviour since
those addresses should forward to the correct host. I've tried those
four at ericsson.se with no response thus far. Next step is to try
newstoo.ericsson.se and then to see who their upstream is. Someone else
may need to do that though since I'm off overseas tomorrow.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Enjoy life... This is not a rehearsal.
------------------------------
Date: 18 Nov 2000 17:46:27 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: multidimensional array help
Message-Id: <8v74cj$ibn$1@boomer.cs.utexas.edu>
In article <3A16A67E.AACEB428@cloud9.net>, brian <polar@cloud9.net> wrote:
>I am having trouble setting up a multidimensional array.
That might be because Perl doesn't support multidimensional arrays. It
just supports arrays whose individual values happen to be references to
other arrays.
>Assume I have
>two arrays @aaa ( 1..5) and @bbb (6..10).
I'm assuming that by this you mean you have two arrays like what you
might get if you did this:
@aaa = ( 1, 2, 3, 4, 5 );
@bbb = ( 6, 7, 8, 9, 10 );
> I am trying to set ccc = (
>[\@aaa] , [\@bbb] ) .
Meaning, you'ld like $foo[0][0] to be 1 and $foo[1][3]
to be 9? In that case, just create references to your
arrays by using backslash when you refer to them:
@foo = ( \@aaa, \@bbb );
Alternately, you can do it in two steps:
$foo[0] = \@aaa;
$foo[1] = \@bbb;
Or, if you'd like to copy them instead of just storing references
to them, use the square brackets operator, which creates a
reference to an array containing the list of stuff inside the
brackets. Then, put your array in the brackets so it gets turned
into a list that the square brackets operator can copy:
@foo = ( [ @aaa ], [ @bbb ] );
Or, again, in two steps:
$foo[0] = [ @aaa ];
$foo[1] = [ @bbb ];
>I have tried using $ccc and @ccc = = ( [\@aaa] ,
>[\@bbb] )
When you do
@ccc = ( [ \@aaa ], [ \@bbb ] );
it takes the array aaa, and then creates a reference to it. It
then forms a list containing just this reference, stores that
list in an array and creates a reference to that array. It does
the same thing with bbb, and in the end, @ccc ends up being an
array containing two elements. Each element is a reference to an
array which happens to contain one element which is a reference
to another array which happens to contain five elements.
In other words, you're creating too many levels of reference that way.
> I read thru several of
>the help pages and I have no problem accessing the data if I use @= (
>[1..5] , [6..10] ) but i can't acces the data when I'm passing it
>another array.
Just remember that when "1..5" is used in a list context, it ends
up having the value of a list of the numbers starting at 1 and
ending at 5. When you use "@x" in a list context, it ends up
having the value of a list of everything that's in the array.
Hope that helps.
- Logan
------------------------------
Date: Sat, 18 Nov 2000 18:29:38 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: multidimensional array help
Message-Id: <slrn91e472.uq.tadmc@magna.metronet.com>
On Sat, 18 Nov 2000 15:55:43 +0000, brian <polar@cloud9.net> wrote:
>I am having trouble setting up a multidimensional array. Assume I have
>two arrays @aaa ( 1..5)
In Perl (we can speak Perl here, it communicates more clearly
than English) we say that like this:
my @aaa = ( 1..5) ;
> and @bbb (6..10).
my @bbb = (6..10);
>I am trying to set ccc = (
>[\@aaa] , [\@bbb] ) .
I doubt that you want what you have just said you want...
>I have tried using $ccc and @ccc = = ( [\@aaa] ,
>[\@bbb] ) but I can still not access the array.
We cannot debug code that we cannot see.
What code did you use to try and access the array?
>I read thru several of
>the help pages and I have no problem accessing the data if I use @= (
>[1..5] , [6..10] )
That is an entirely different data structure. It is one level
"shallower" than your other structures above.
I expect that this is what you really want.
You can do that either (but not both!) of the ways you tried above.
Either backslash a named array, or create an anonymous array.
Choose whichever one has the semantics that you want:
----------------------
#!/usr/bin/perl -w
use strict;
my @aaa = (1..5);
my @bbb = (6..10);
#my @ccc = ( [ 1..5 ], [ 6..10 ] ); # @ccc gets 2 of its own arrays
#my @ccc = ( \@aaa, \@bbb ); # @cc shares 2 arrays with main
my @ccc = ( [ @aaa ], [ @bbb ] ); # @ccc gets 2 of its own arrays whose
# contents are _copied_ from arrays
foreach my $aref ( @ccc ) {
foreach my $data ( @{$aref} ) {
print "$data\n";
}
print "----------\n";
}
----------------------
>but i can't acces the data when I'm passing it
>another array. I'm sure I'm missing somethig very easy but could
>someone please help me out.
You are doing too good a job of "taking a reference to an array".
You are doing it twice. You are taking a reference to a reference
to an array.
Your data structure is likely one level deeper than what you
planned on (I think, can't tell because your description above
takes 2 refs and that just seems pretty strange).
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Nov 2000 19:05:12 -0500
From: "David Marvil" <captmarvil@rcn.com>
Subject: Perl beginner
Message-Id: <8v75dn$jba$1@bob.news.rcn.net>
I am just starting out and am trying to write a script that will allow me
to enter a user name at the command prompt, parse a file that has user names
and IP's and then match the the corresponding user name that was entered at
the command prompt with an IP and print out the username and their matching
IP. It is also important that the match be case insensitive I also might
mention that I am playing with this on my Linux machine but I am hoping to
use this script at work on a WinNT box. I appreciate any help. Thanks
#! /usr/bin/perl -w
print "Enter users name: ";
chomp ($user = <STDIN>);
open (FILE, "/user_info") || die "File not found";
while (<FILE>) {
chomp;
($name, $ip) = /(\w+\s+\w+)\s+(\d+\.\d+\.\d+\.\d+)/;
$a{$name} = $ip;
}
$name = $user;
print "$user\t"$a{name};
------------------------------
Date: 19 Nov 2000 01:39:31 GMT
From: jiegao@mail.usyd.edu.au (Jie Gao)
Subject: perl man pages
Message-Id: <8v7b0j$mkb$1@spacebar.ucc.usyd.edu.au>
Keywords: perl man pages
Hi,
System: Solairs/Sparc 5.7
-------------------------
Perl version: 5.6.
It seems perl man pages are not indexed correctly (windex). For example, I have run:
$ catman -M /usr/local/man -w
$ man -k XML::Parser # Nothing returned.
$ man -k Parser
\&HTML \&HTML (3) - Alternative HTML::Parser interface
HTML HTML (3) - Alternative HTML::Parser interface
Parse Parse (3) - Generate Recursive-Descent Parsers
$ man XML::Parser
No manual entry for XML::Parser.
This happens to other modules as well.
Jie
P.S.: Please e-mail any reply.
--
------------------------------
Date: Sat, 18 Nov 2000 20:49:33 -0500
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: perl man pages
Message-Id: <brian+usenet-F0E11B.20493318112000@news.panix.com>
In article <8v7b0j$mkb$1@spacebar.ucc.usyd.edu.au>,
jiegao@mail.usyd.edu.au (Jie Gao) wrote:
> It seems perl man pages are not indexed correctly (windex). For example, I have run:
>
> $ catman -M /usr/local/man -w
> $ man -k XML::Parser # Nothing returned.
> $ man -k Parser
> \&HTML \&HTML (3) - Alternative HTML::Parser interface
> HTML HTML (3) - Alternative HTML::Parser interface
> Parse Parse (3) - Generate Recursive-Descent Parsers
> $ man XML::Parser
> No manual entry for XML::Parser.
do you have XML::Parser installed and have its man pages in the right
place?
--
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v71qn$ban$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v73iv$f63$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v75b8$jr6$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v773h$om7$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v78rp$shv$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v7ak1$2u4$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: 18 Nov 2000 23:26:33 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: simple question: can Perl do this? (talking to a permanent opened prog.)
Message-Id: <8v7379$1g3$1@lublin.zrz.tu-berlin.de>
Honza Pazdziora <adelton@informatics.muni.cz> wrote in comp.lang.perl.misc:
>On Sat, 18 Nov 2000 15:58:26 -0800, Mauro <-@-.com> wrote:
>> I think this is a simple question but I can't figure out how can I do it:
>> I've a site with a PERL CGI that performs thousands of consecutive
>> substitutions like:
>>
>> $foobar=~s/.*un.*/one/;
>> $foobar=~s/.*deux.*/two/;
>> $foobar=~s/.*trois.*/three/;
>> $foobar=~s/.*quatre.*/four/;
>> $foobar=~s/.*cinq.*/five/;
>> and so on...
>>
>> doing thousands of theese substitutions takes too much time in perl
>
>How about
>
> my %translate = qw(
> un one
> deux two
> trois three
> quatre four
> cinq five
> );
> my $keys = join '|', keys %translate;
> $foobar =~ s/.*($keys).*/$translate{$keys}/e;
Surely you mean "$foobar =~ s/.*($keys).*/$translate{$1}/e;"
If so, you don't need the /e modifier, the right-hand side of s///
is string-interpolated at run-time.
Like the code the OP shows above, this will replace the entire text
in $foobar with the translation of the first keyword that happens to
match. This doesn't look right, and the intended purpose is probably
closer to
$foobar =~ s/($keys)/$translate{$1}/g;
Of course, if $foobar is allowed to contain arbitrary French text,
don't be surprised to see "oneiverse" and "hitwo" in the translation.
With restricted text, this approach may suffice.
Anno
------------------------------
Date: Sat, 18 Nov 2000 18:35:24 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: simple question: can Perl do this? (talking to a permanent opened prog.)
Message-Id: <8v73ne$lm6$1@slb7.atl.mindspring.net>
"Mauro" <-@-.com> wrote in message news:8v65db$4nd$1@nslave3.tin.it...
> I've a site with a PERL CGI that performs thousands of consecutive
> substitutions like:
>
> $foobar=~s/.*un.*/one/;
> $foobar=~s/.*deux.*/two/;
> $foobar=~s/.*trois.*/three/;
> $foobar=~s/.*quatre.*/four/;
> $foobar=~s/.*cinq.*/five/;
> and so on...
A few issues here;
1) Do you really want the RE to take the entire string that contains 'un'
and replace it with a string containing nothing but 'one'?
$foobar = q(un moment, s'il vous plait);
$foobar=~s/.*un.*/one/;
print $foobar;
# prints 'one';
2) What happens if the string contains a matching expression embedded in
another word?
$foobar = q(un flacon de Bordeux);
$foobar=~s/.*deux.*/two/;
print $foobar;
# prints 'two'
3) What if one of the thousands of translations consists of a string that is
a substring of another translation? The RE will perform the first match,
not necessarily the best match.
I have modified Honza's code to address these issues. I also fixed a small
bug in the code - $translate{$keys} will always be undefined, as there is no
hash element that consists of the joined search string. I know he meant to
use $1 instead ;)
# Build the lookup hash
my %translate = qw(
un one
deux two
trois three
quatre four
cinq five
);
# Build the search string, sorting DESCENDING BY LENGTH, so that
# big words match before little ones do.
my $keys = join '|', sort { length($b) <=> length($a) } keys %translate;
# Perform a global substitution, matching on word boundaries
$foobar =~ s/\w($keys)\w/$translate{$1}/ge;
Of course, if my ESP was wrong and Honza's code does what you want (with the
$1 fix), please disregard these ramblings.
Kurt Stephens
------------------------------
Date: Sat, 18 Nov 2000 18:57:06 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: simple question: can Perl do this? (talking to a permanent opened prog.)
Message-Id: <slrn91e5qh.uq.tadmc@magna.metronet.com>
On Sat, 18 Nov 2000 17:18:39 GMT, Honza Pazdziora <adelton@fi.muni.cz> wrote:
>On Sat, 18 Nov 2000 15:58:26 -0800, Mauro <-@-.com> wrote:
>> I think this is a simple question
You (the OP) also have a Frequently Asked Question:
"How do I efficiently match many regular expressions at once?"
>> but I can't figure out how can I do it:
Adapting the answer given in the FAQ would be a good first try.
>> I've a site with a PERL CGI that performs thousands of consecutive
>> substitutions like:
[snip]
>How about
>
> my %translate = qw(
> un one
> deux two
> trois three
> quatre four
> cinq five
> );
> my $keys = join '|', keys %translate;
Your mistake there bit me once. After a long debugging session
it came down to Perl's left-to-right pattern matching.
/(cinq|cinqty)/
the second alternative can never match.
So I either wrap it in word boundaries:
/\b(cinq|cinqty)\b/
or make sure the longer one will be leftmost:
my $keys = join '|', reverse sort keys %translate;
> $foobar =~ s/.*($keys).*/$translate{$keys}/e;
Well we're trying to get faster here, so s///e is moving in
the wrong direction. Particularly since it is not even needed!
And if we are not planning on changing $keys, perl will go lots
faster if we tell it that we won't be changing it: s///o
And you are deleting lots of characters there too. Probably
don't want those dot-stars in the pattern :-)
Did you test this code before posting it?
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Nov 2000 20:37:53 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: simple question: can Perl do this? (talking to a permanent opened prog.)
Message-Id: <8v7art$bqg$1@slb3.atl.mindspring.net>
"Kurt Stephens" <kstep@pepsdesign.com> wrote in message
news:8v73ne$lm6$1@slb7.atl.mindspring.net...
> # Perform a global substitution, matching on word boundaries
> $foobar =~ s/\w($keys)\w/$translate{$1}/ge;
Doh! I meant /\b($keys)\b/!
Thanks Anno, I realize we don't need the /e.
# Perform a global substitution, matching on word boundaries
$foobar =~ s/\b($keys)\b/$translate{$1}/g;
That's more like it.
------------------------------
Date: Sat, 18 Nov 2000 19:28:29 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: views and/or cursors with DBD::mysql ??
Message-Id: <8v76pq$pc3$1@slb3.atl.mindspring.net>
"StevieD" <stevie_d38nospam@hotmail.com> wrote in message
news:5qCR5.30$Uj7.70159@nnrp2.sbc.net...
> Hi - moderate perl ability, only simple SQL knowledge ... i can't for the
> life of me find any documentation or get anything to work in order to
create
> a temporary table or cursor or define a table view using DBD::mysql ...
As far as I know, MySQL does not support cursors, views or stored
procedures. This is not an issue with DBI or Perl, but with the database
itself. In the examples that you gave, a simple SELECT statement would
suffice, however unlike a view the query must be prepared every time that it
is run.
You may want to check the documentation concerning the HEAP table type,
which appears to be a form of temporary table that persists in RAM only.
You can find the complete MySQL documentation at
http://www.mysql.com/documentation/.
Kurt Stephens
------------------------------
Date: Sat, 18 Nov 2000 19:28:32 -0600
From: "StevieD" <stevie_d38nospam@hotmail.com>
Subject: Re: views and/or cursors with DBD::mysql ??
Message-Id: <z%FR5.77$Uj7.128857@nnrp2.sbc.net>
How funny, i was just there reading about HEAP types a bit ago. However,
running their example of creating a table of that type yields syntax error:
DBD::mysql::db do failed: You have an error in your SQL syntax near
'type=heap select * from temp1' at line 1 at view.cgi line 51.
If i can use SELECT statements that'd be great; i just don't understand how
to do 2 selects to create 2 recordsets, then be able to a SELECT for my
desired output that refers to both recordsets (using an inner join and
aggregate functions) ... If i can't store them in views or cursors, how can
i reference them in my final SELECT statement?
-Steve
PS - Does the fact that these transactions are in a perl script on a
webserver impact any of the syntax issues?
"Kurt Stephens" <kstep@pepsdesign.com> wrote in message
news:8v76pq$pc3$1@slb3.atl.mindspring.net...
> As far as I know, MySQL does not support cursors, views or stored
> procedures. This is not an issue with DBI or Perl, but with the database
> itself. In the examples that you gave, a simple SELECT statement would
> suffice, however unlike a view the query must be prepared every time that
it
> is run.
>
> You may want to check the documentation concerning the HEAP table type,
> which appears to be a form of temporary table that persists in RAM only.
>
> You can find the complete MySQL documentation at
> http://www.mysql.com/documentation/.
>
> Kurt Stephens
------------------------------
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 4920
**************************************