[23188] in Perl-Users-Digest
Perl-Users Digest, Issue: 5409 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 22 11:07:55 2003
Date: Fri, 22 Aug 2003 08:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 22 Aug 2003 Volume: 10 Number: 5409
Today's topics:
Re: \@rray, error? maybe not. <Ben_Dover@psychiatric-center.Bellevue-Hospital.com>
Re: \@rray, error? maybe not. <uri@stemsystems.com>
Re: Apache returns 200 OK, but my perl script sends 302 <flavell@mail.cern.ch>
Re: comparison with functions ord and length <nobull@mail.com>
Emacs debugger and perl fork (Kelly Corcam)
EZDB (Ryan)
File transfers (SRam)
Re: File transfers <nobull@mail.com>
Re: Image::Magick jpeg compression <kuujinbo@hotmail.com>
Re: Killing frozen system("something.exe") call - how? <Graham.T.Wood@oracle.com>
Large File transfers using sockets in Perl or any metho (SRam)
Re: Large File transfers using sockets in Perl or any m <nobull@mail.com>
Re: Module::Build is yet more broken... <tzz@lifelogs.com>
Re: Module::Build is yet more broken... <nospam-abuse@ilyaz.org>
Re: Module::Build is yet more broken... <tzz@lifelogs.com>
Newbie File Question <nospam@goawayspam.com>
Re: Newbie File Question <bigj@kamelfreund.de>
Re: operator in a variable? <tzz@lifelogs.com>
Re: operator in a variable? <tzz@lifelogs.com>
Re: operator in a variable? <tassilo.parseval@rwth-aachen.de>
Re: operator in a variable? <nobull@mail.com>
Re: operator in a variable? (Sam Holden)
Re: perl data transfer <sv99oya02@sneakemail.com>
Resend: using Getopt::Long with option value having spa <sunil_franklin@hotmail.com>
string matching (kamal)
Re: string matching <sv99oya02@sneakemail.com>
Re: string matching <noreply@gunnar.cc>
Re: string matching <nobull@mail.com>
Using DBI from within Apache (Hog Spog)
Re: Using DBI from within Apache <nobull@mail.com>
Re: Using DBI from within Apache <Graham.T.Wood@oracle.com>
Re: Using DBI from within Apache (Tony)
Re: XML parsing problem <newsguy@xmltwig.com>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 22 Aug 2003 09:48:53 -0400
From: Ben Dover - Mental Patient 0057 <Ben_Dover@psychiatric-center.Bellevue-Hospital.com>
Subject: Re: \@rray, error? maybe not.
Message-Id: <3F461F45.792C667F@psychiatric-center.Bellevue-Hospital.com>
thanks all!
Janek Schleicher wrote:
>
> Ben Dover - Mental Patient 0057 wrote at Thu, 21 Aug 2003 16:05:31 -0400:
>
> > I'm looking at another persons code and I saw what I thought was an
> > error, but it seems to be in more than one place.
> >
> > the following line for example:
> > ($web{open},$web{dates},$web{stat}) = classStat($loc,\@classes);
>
> Allthough the \ is correct (as Tad already has explained),
> there is IMHO still something that could be improved.
> I personally would write the assignment not as an
> assignment to 3 different hash elements, but to a hash slice of 3 elements
> of the same hash:
>
> (@web{qw/open dates stat/}) = classStat($loc,\@classes);
>
> That has the advantage of being shorter and removing unnecessary doubled
> code what could get a problem for maintainance in future.
> It has the more important advantage that the main idea is expressed more
> directly:
> Set the values for some keys of the %web hash.
>
> Greetings,
> Janek
------------------------------
Date: Fri, 22 Aug 2003 14:47:51 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: \@rray, error? maybe not.
Message-Id: <x7y8xlpx48.fsf@mail.sysarch.com>
>>>>> "JS" == Janek Schleicher <bigj@kamelfreund.de> writes:
JS> (@web{qw/open dates stat/}) = classStat($loc,\@classes);
since that is a hash slice which provides list context, you can lose the
surrounding parens.
@web{ qw(open dates stat) } = classStat($loc,\@classes);
and qw with parens is easier to read there IMO. in general i don't like
qw with // anyway but i tolreate it in use lines because that is
popular.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 22 Aug 2003 12:43:30 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Apache returns 200 OK, but my perl script sends 302 REDIRECT
Message-Id: <Pine.LNX.4.53.0308221230170.4554@lxplus100.cern.ch>
On Thu, Aug 21, Michel Tokic top-posted above a fullquote[1]:
> Dan,
>
> thanks for your help. My script is a little complicated,
Then remove the complications, and concentrate on the point at issue.
Elementary problem solving technique.
> and calls some functions of a self written module.
The CGI interface cares nothing for how you generated your CGI
response. It could be generated by a team of penguins pecking at
punch cards for all it cares: the only thing that matters is that the
result conforms to the CGI specification.
> Depending on the parameters, it gives a special output to the user.
Keep in mind that a CGI script returns its results to the _server_,
according to the CGI interface specification (well, OK, you're doing
mod_perl, but the principle is analogous).
The resulting HTTP transaction response to the user's client software
is generated by the server on the basis of the CGI response. The
distinction is sometimes important.
> But one function is, to relocate to
> a special site, when eg. the delete-function is called. Just to prevent,
> that the user don't can reload the page with the browsers built-in
> reload-button.
You still haven't stated clearly what you want to happen; what is
actually happening; and why you think that what is happening isn't
consistent with what you asked for in your CGI response.
> So just doing generated HTML output isn't enough for me ;-)
Telling us what you _don't_ want, when you still haven't made it clear
what you _do_ want, isn't so helpful.
> Another idea?
Only the same idea as before: State your problem, clearly.
http://www.catb.org/~esr/faqs/smart-questions.html#bespecific
[1] and adjust your response style to the long-established Usenet
conventions. If you don't know what they are then you haven't been
reading usenet for long enough to be able to get productive benefit
out of it.
------------------------------
Date: 22 Aug 2003 14:26:32 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: comparison with functions ord and length
Message-Id: <u9vfspvn5j.fsf@wcl-l.bham.ac.uk>
simjesse@aol.com (Bohne) writes:
> Can somebody explain the following to me?
>
> if (int ((((ord($STRING) - 32) & 077) + 2) / 3) == int(length($STRING) / 4))
Can you expalin which of the operators or functions you could not find
in the manuals, we should be able to direct you to the correct page.
> This case seems to be true if $STRING has been uuencoded, false otherwise.
From that statement I conclude that the first character of a line of a
uuencoded string encodes the length. (I didn't previously know that).
Of course the above identity would also be true for some strings that
were not valid uuencoded strings or, of couse, strings that just
happen to be the same as uuencoded strings but actually came from
another source.
> I just don't seen to be able to figure out why!
It's probably because the first character of a line of a uuencoded
string encodes the length.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 22 Aug 2003 08:00:55 -0700
From: kcorcam@yahoo.com (Kelly Corcam)
Subject: Emacs debugger and perl fork
Message-Id: <cdd61647.0308220700.3e8731b3@posting.google.com>
Does anyone know how to use emacs
perl debugger to debug a forked child
process? I want to be able to open
another emacs window for each child
process so that I can debug it.
Is this possible?
Thanks,
Kelly
------------------------------
Date: 22 Aug 2003 07:47:40 -0700
From: rlbowley@email.com (Ryan)
Subject: EZDB
Message-Id: <77d65ebf.0308220647.33ed0afe@posting.google.com>
Hello,
I am using ezperl's ezdb 3.0, and am hoping anyone with some
experience can help me out. ezperl's website does not offer any help
and the forum on that website is not working, and hasn't been for
sometime now, and email's go unanswered.
The problem I am having is when ezdb returns a search result with more
than 20 entries it will display just the first 20, then put a
hyperlink at the bottom of the page to view the next page. The format
of the hyperlink is:
http://www.foobar.com/cgi-bin/ezdb.cgi?database+search+retrieve&session_id&page-range&keyword&%%%%db=20......
now when anyone clicks this link that is not using netscape 6, it
works as expected. If they are using netscape 6 then they get this
error:
25db no such field name in database.
in the address bar of the browser the url reads:
http://www.foobar.com/cgi-bin/ezdb.cgi?database+search+retrieve&session_id&page-range&keyword&%25%25%25%25db=20......
so you can see where it is getting the: 25db no such field name in
database. So it appears that netscape somehow is posting formated
urls to the cgi script, and it is mis interprting the data.
I have found that all the information after keyword is unneccesary,
because the info it is passing the script is already contained in the
config files for the database, so it's redundent realy.
I don't want to go into the script and modify it to drop the last part
of the URL if I can avoid it. Has anyone had any problem of this
sort? Am I cutting my own throat by using EZDB? It does seem like
support for ezdb has gone out the window. Any help would be
appreciated.
Thanks
Ryan
------------------------------
Date: 22 Aug 2003 05:38:08 -0700
From: aksivaram2k2@yahoo.com (SRam)
Subject: File transfers
Message-Id: <20ffa179.0308220438.26c30aeb@posting.google.com>
What is the limit of syswrite function. How can I convert an image
from binary mode so as to store it in a buffer and send it to client
and the client has to again decode the same to display the image
------------------------------
Date: 22 Aug 2003 14:18:28 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: File transfers
Message-Id: <u94r09x23f.fsf@wcl-l.bham.ac.uk>
aksivaram2k2@yahoo.com (SRam) writes:
> Subject: File transfers
> What is the limit of syswrite function.
It does what it does. It does not make tea or wash the dishes.
What did you really mean?
You you mean what is the largest number of bytes that you can assume
will be sent by a single syswrite()? This is dependant on many
factors and it not something you should ever depend on for
character-stream based filedescriptors.
> How can I convert an image from binary mode
What do you mean by "convert an image from binary mode" you mean into
a text based image format like XPM or PDF?
> so as to store it in a buffer
What does this have to do with anything above. What do you mean by
buffer? Do you mean scalar variable or do you mean something else.
> and send it to client
"Client"? Where has any client/server architecture been mentioned.
> and the client has to again decode the same to display the image
All images need some kind of "decoding" before they are displayed.
Are you really talking about encryption? Are you really talking about
compression?
I think you have a problem partitioning proplem. You have a large
problem and you have picked a few random half-phrases from diffent
parts of the problem and strung them together. They do not form a
coherent description of anything.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 22 Aug 2003 21:31:46 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Image::Magick jpeg compression
Message-Id: <bi52mm$bv4$1@pin3.tky.plala.or.jp>
Andrew Harton wrote:
> Andrew Harton wrote:
>
>>Hi all,
>>
>>I've been banging my head against a wall trying to use Image::Magick
>>to generate jpeg compressed thumbnails.
I had the same problem a while back, and likewise found the docs a bit
sparse. Guessing you're on a M$ platform (message headers??), which
should have added the ImageMagick *system* executables to your path. Its
a kludge, using convert, which in the documentation
(http://studio.imagemagick.org/www/convert.html):
"converts an input file using one image format to an output file with a
differing image format."
Anyway, tested on W2K, ImageMagick 5.5.7, Activestate 635:
use strict;
use warnings;
use File::Basename;
use Image::Magick;
resize_jpgs(@ARGV); #pass in full pathnames
sub resize_jpgs {
my (@files) = @_;
my @sizes = qw[400 100];
foreach my $file(@files) {
foreach my $size(@sizes) {
my ($name,$path) = fileparse($file);
my $new_jpg = ($size == 400) ? "$path/s-$name" : "$path/t-$name";
my @args =
('convert','-size',$size,$file,'-resize',$size,'+profile','"*"',$new_jpg);
# system(@args) == 0 or warn "Couldn't resize $file\n";
system(@args);
}
}
}
You *will* get warnings to the effect that the file couldn't be opened,
but it works nonetheless. System returns 1...anyone have an idea why
return value isn't zero, despite the fact that the conversions succeeed?
HTH - keith
------------------------------
Date: Fri, 22 Aug 2003 12:08:39 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Killing frozen system("something.exe") call - how?
Message-Id: <3F45F9B7.5AF92461@oracle.com>
This is a multi-part message in MIME format.
--------------3628CDF636A8E625AFEC8DB2
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Alexandre Bougakov more or less wrote:
> I wrote a small script that calls
>
> system ("${doc2text_path}doc2text.exe -d cp1251 ${filename} >
> ${temp}output.txt");
>
> can I make Perl to stop waiting for a called external
> program to finish after one minute
You could use the Win32::Process module instead of system. That would
give you more control over the external process, including the option of
waiting for one minute and killing it. You get Win32::Process with
Activestate perl so you can read how to use it with "perldoc
Win32::Process"
Hope this helps.
Graham
--------------3628CDF636A8E625AFEC8DB2
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------3628CDF636A8E625AFEC8DB2--
------------------------------
Date: 22 Aug 2003 03:14:15 -0700
From: aksivaram2k2@yahoo.com (SRam)
Subject: Large File transfers using sockets in Perl or any method if available
Message-Id: <20ffa179.0308220214.30986b7d@posting.google.com>
I am working out to develop client server application using perl.
Client & Server commuicate using sockets. server executes a query and
the o/p is a list of documents. How can I transfer these documents
from server to client..i.e we execute and o/p is documents to be
transferred from server. From client I have to receive and view the
documents..urgent..plz mail ASAP.....
------------------------------
Date: 22 Aug 2003 14:20:36 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Large File transfers using sockets in Perl or any method if available
Message-Id: <u9zni1vnff.fsf@wcl-l.bham.ac.uk>
aksivaram2k2@yahoo.com (SRam) writes:
> I am working out to develop client server application using perl.
> Client & Server commuicate using sockets. server executes a query and
> the o/p is a list of documents. How can I transfer these documents
> from server to client..
FTP
E-mail
HTTP
> i.e we execute and o/p is documents to be
> transferred from server. From client I have to receive and view the
> documents..urgent..plz mail ASAP.....
You appear to be panicing and so you are not making any sense. You
need to take some deep breaths ans work out what it is you are trying
to ask.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 22 Aug 2003 06:19:55 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Module::Build is yet more broken...
Message-Id: <4nekzej8ok.fsf@lockgroove.bwh.harvard.edu>
On Thu, 21 Aug 2003, nospam-abuse@ilyaz.org wrote:
> [A complimentary Cc of this posting was sent to Sam Holden
> <sholden@cs.usyd.edu.au>], who wrote in article
> <slrnbk82lp.6sp.sholden@flexal.cs.usyd.edu.au>:
>> perl Setup.PL
>> perl Build.PL test
>> perl Build.PL install
>>
>> is hardly 20 pages.
>
> Would this be the case, great. However, I still have no idea why
> the second line is needed... IMO, the default should be to do
> config/build/test cycle; and it is better to keep install a
> different command.
I don't think running tests should be a part of the config/build
process. It's not now.
Ted
------------------------------
Date: Fri, 22 Aug 2003 13:23:16 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Module::Build is yet more broken...
Message-Id: <bi55g4$2a2g$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Ted Zlatanov
<tzz@lifelogs.com>], who wrote in article <4nekzej8ok.fsf@lockgroove.bwh.harvard.edu>:
> >> perl Setup.PL
> >> perl Build.PL test
> >> perl Build.PL install
> > Would this be the case, great. However, I still have no idea why
> > the second line is needed... IMO, the default should be to do
> > config/build/test cycle; and it is better to keep install a
> > different command.
>
> I don't think running tests should be a part of the config/build
> process. It's not now.
I'm not discussing any "process". What I'm discussing is the
*default* action. E.g., the above sequence can be modelled by
perl Setup.PL do=config do=build
perl Setup.PL do=test
perl Setup.PL do=install
or by
perl Setup.PL do=config do=build do=test do=install
My suggestion is that it should be equivalent to
perl Setup.PL
perl Setup.PL do=install
or
perl Setup.PL do=all
(with syntax subject to change).
Hope this helps,
Ilya
------------------------------
Date: Fri, 22 Aug 2003 10:10:21 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Module::Build is yet more broken...
Message-Id: <4nlltlhjg2.fsf@lockgroove.bwh.harvard.edu>
On Fri, 22 Aug 2003, nospam-abuse@ilyaz.org wrote:
> [A complimentary Cc of this posting was sent to Ted Zlatanov
> <tzz@lifelogs.com>], who wrote in article
> <4nekzej8ok.fsf@lockgroove.bwh.harvard.edu>:
>> >> perl Setup.PL
>> >> perl Build.PL test
>> >> perl Build.PL install
>
>> > Would this be the case, great. However, I still have no idea why
>> > the second line is needed... IMO, the default should be to do
>> > config/build/test cycle; and it is better to keep install a
>> > different command.
>>
>> I don't think running tests should be a part of the config/build
>> process. It's not now.
>
> I'm not discussing any "process". What I'm discussing is the
> *default* action. E.g., the above sequence can be modelled by
>
> perl Setup.PL do=config do=build
> perl Setup.PL do=test
> perl Setup.PL do=install
>
> or by
>
> perl Setup.PL do=config do=build do=test do=install
>
> My suggestion is that it should be equivalent to
>
> perl Setup.PL
> perl Setup.PL do=install
>
> or
>
> perl Setup.PL do=all
>
> (with syntax subject to change).
Right, I understand, and still don't think running tests should be a
part of any default action. You should have to explicitly request the
tests (with do=test or do=all in your example).
Ted
------------------------------
Date: Fri, 22 Aug 2003 14:17:51 GMT
From: "Kubaton Lover" <nospam@goawayspam.com>
Subject: Newbie File Question
Message-Id: <jCp1b.75$Ya3.9@news.randori.com>
I have a perl script that currently opens a file and prints its contents to
the web browser like so...
open (CODE, $file) || die;
while (<CODE>) {
print $_;
}
close CODE;
I need to change the code to read and output just the first line, then I'll
output some custom stuff, then I need to output the rest of the file;
something like the following pseudocode:
open (CODE, $file) || die;
print first line;
print my stuff here;
print rest of file;
close CODE;
Your help is appreciated.
------------------------------
Date: Fri, 22 Aug 2003 16:07:46 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Newbie File Question
Message-Id: <pan.2003.08.22.14.07.46.99970@kamelfreund.de>
Kubaton Lover wrote at Fri, 22 Aug 2003 14:17:51 +0000:
> I have a perl script that currently opens a file and prints its contents to
> the web browser like so...
>
> open (CODE, $file) || die;
> while (<CODE>) {
> print $_;
> }
> close CODE;
>
>
> I need to change the code to read and output just the first line, then I'll
> output some custom stuff, then I need to output the rest of the file;
> something like the following pseudocode:
>
> open (CODE, $file) || die;
> print first line;
> print my stuff here;
> print rest of file;
> close CODE;
>
> Your help is appreciated.
E.g.
open CODE, $file or die $!; # I would also add the error code
print scalar <CODE>; # print first line
print $your_stuff;
while (<CODE>) {
print; # the $_ is redundant here
}
close CODE;
Greetings,
Janek
------------------------------
Date: Fri, 22 Aug 2003 06:03:55 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: operator in a variable?
Message-Id: <4nn0e2j9f8.fsf@lockgroove.bwh.harvard.edu>
On Fri, 22 Aug 2003, bigj@kamelfreund.de wrote:
> my $result = eval "$x $op $y";
> print $result;
This won't work correctly for operators that modify either variable,
because you interpolate $x and $y also; you probably want
my $result = eval "\$x $op \$y";
Ted
------------------------------
Date: Fri, 22 Aug 2003 06:11:48 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: operator in a variable?
Message-Id: <4nisoqj923.fsf@lockgroove.bwh.harvard.edu>
On 22 Aug 2003, sholden@flexal.cs.usyd.edu.au wrote:
> my %ops = ( '+' => sub {return $_[0] + $_[1]},
> '-' => sub {return $_[0] - $_[1]},
> );
>
> my $x = 123;
> my $y = 456;
>
> for my $op ('+', '-') {
> my $result = $ops{$op}($x, $y);
> print "$x $op $y = $result\n";
> }
In case the operator needs to modify $x or $y, I would do it thus:
$ops{'+'} = sub { my $xr = shift; my $yr = shift; return $$xr + $$yr; };
my $result = $ops{$op}->(\$x, \$y);
Ted
------------------------------
Date: 22 Aug 2003 10:52:49 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: operator in a variable?
Message-Id: <bi4sm1$345$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Ted Zlatanov:
> On 22 Aug 2003, sholden@flexal.cs.usyd.edu.au wrote:
>
>> my %ops = ( '+' => sub {return $_[0] + $_[1]},
>> '-' => sub {return $_[0] - $_[1]},
>> );
>>
>> my $x = 123;
>> my $y = 456;
>>
>> for my $op ('+', '-') {
>> my $result = $ops{$op}($x, $y);
>> print "$x $op $y = $result\n";
>> }
>
> In case the operator needs to modify $x or $y, I would do it thus:
>
> $ops{'+'} = sub { my $xr = shift; my $yr = shift; return $$xr + $$yr; };
>
> my $result = $ops{$op}->(\$x, \$y);
It's not necessary. @_ contains aliases to the variables that were
passed to the functions so altering them will alter the original values
as well.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 22 Aug 2003 14:05:53 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: operator in a variable?
Message-Id: <u98yplx2oe.fsf@wcl-l.bham.ac.uk>
Ted Zlatanov <tzz@lifelogs.com> writes:
> On 22 Aug 2003, sholden@flexal.cs.usyd.edu.au wrote:
>
> > my %ops = ( '+' => sub {return $_[0] + $_[1]},
> > '-' => sub {return $_[0] - $_[1]},
> > );
> >
> > my $x = 123;
> > my $y = 456;
> >
> > for my $op ('+', '-') {
> > my $result = $ops{$op}($x, $y);
> > print "$x $op $y = $result\n";
> > }
>
> In case the operator needs to modify $x or $y, I would do it thus:
>
> $ops{'+'} = sub { my $xr = shift; my $yr = shift; return $$xr + $$yr; };
>
> my $result = $ops{$op}->(\$x, \$y);
That uglyness is quite unnecessary. The elements of @_ are _alaises_,
not copies, of the aguments passed to a subroutine.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 22 Aug 2003 14:51:07 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: operator in a variable?
Message-Id: <slrnbkcber.lk7.sholden@flexal.cs.usyd.edu.au>
On Fri, 22 Aug 2003 06:11:48 -0400, Ted Zlatanov <tzz@lifelogs.com> wrote:
> On 22 Aug 2003, sholden@flexal.cs.usyd.edu.au wrote:
>
>> my %ops = ( '+' => sub {return $_[0] + $_[1]},
>> '-' => sub {return $_[0] - $_[1]},
>> );
>>
>> my $x = 123;
>> my $y = 456;
>>
>> for my $op ('+', '-') {
>> my $result = $ops{$op}($x, $y);
>> print "$x $op $y = $result\n";
>> }
>
> In case the operator needs to modify $x or $y, I would do it thus:
>
> $ops{'+'} = sub { my $xr = shift; my $yr = shift; return $$xr + $$yr; };
>
> my $result = $ops{$op}->(\$x, \$y);
$ops{'+='} = sub {$_[0] += $_[1]};
($x, $y) = (123, 456);
$ops{'+='}($x, $y);
print "$x\n";
Is the obvious example that shows you don't need to make the code
unintuitive even if you want such things.
--
Sam Holden
------------------------------
Date: Fri, 22 Aug 2003 14:18:03 +0200
From: =?ISO-8859-1?Q?Steffen_M=FCller?= <sv99oya02@sneakemail.com>
Subject: Re: perl data transfer
Message-Id: <bi51le$g39$2@news.rz.uni-karlsruhe.de>
SRam wrote:
> I have implemented client/ Server using perl. I wish to know methods
> for transfering large data between those client/ servers. I need to
> transfer large image files between client & server. Can I use ftp or
> any better methods are there
TCP streams? Have a look at the Net:: family of modules via search.cpan.org
Steffen
--
@n=([283488072,6076],[2105905181,8583184],[1823729722,9282996],[281232,
1312416],[1823790605,791604],[2104676663,884944]);$b=6;@c=' -/\_|'=~/./g
;for(@n){for$n(@$_){map{$h=int$n/$b**$_;$n-=$b**$_*$h;$c[@c]=$h}reverse
0..11;push@p,map{$c[$_]}@c[reverse$b..$#c];$#c=$b-1}$p[@p]="\n"}print@p;
------------------------------
Date: Fri, 22 Aug 2003 20:07:56 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: Resend: using Getopt::Long with option value having spaces
Message-Id: <t0q1b.11$3j7.84@news.oracle.com>
All,
I have a text file which has some metadata, like
----
t1.pl -frwk=perl -mode=1 -args=a,b,c -comments="This is comment 1"
t2.sql -frwk=sql -mode=2 -args=x -comments="This is comment 2"
----
I need to read this file line by line and parse it to get the values of
frwk, -mode and comments, so that I can create another string depending on
the different values for this string and pass it on to the corresponding
perl api I have which will execute it for me.
I am stuck because I am not able to pass spaces as part of comments. Is
there a workaround?
I am doing something like the following.
####################################################
my $eval_string = '@ARGV = qw (' . "$scriptOptions" . ' )' ;
eval $eval_string;
GetOptions("fwk=s" => \$framework,
"mode=s" => \$errMode,
"args=s" => \@arguments,
"comments=s" => \$comments );
####################################################
I am using GetOptions as in future the metadata file may have new or
changed options.
Thanks,
Sunil.
------------------------------
Date: 22 Aug 2003 04:39:57 -0700
From: kamal@india.ti.com (kamal)
Subject: string matching
Message-Id: <c34c425d.0308220339.7792e534@posting.google.com>
I need to remove $b from $a
$a = "abc/\def/ghi" ;
$b = "abc/\def";
Regards
Kamal
------------------------------
Date: Fri, 22 Aug 2003 14:17:01 +0200
From: =?ISO-8859-1?Q?Steffen_M=FCller?= <sv99oya02@sneakemail.com>
Subject: Re: string matching
Message-Id: <bi51jg$g39$1@news.rz.uni-karlsruhe.de>
kamal wrote:
> I need to remove $b from $a
>
> $a = "abc/\def/ghi" ;
> $b = "abc/\def";
Simple, really.
$a = "/ghi";
Or try regexes.
$a =~ s/\Q$b//; # Removes first occurrance.
Steffen
--
@n=([283488072,6076],[2105905181,8583184],[1823729722,9282996],[281232,
1312416],[1823790605,791604],[2104676663,884944]);$b=6;@c=' -/\_|'=~/./g
;for(@n){for$n(@$_){map{$h=int$n/$b**$_;$n-=$b**$_*$h;$c[@c]=$h}reverse
0..11;push@p,map{$c[$_]}@c[reverse$b..$#c];$#c=$b-1}$p[@p]="\n"}print@p;
------------------------------
Date: Fri, 22 Aug 2003 14:21:45 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: string matching
Message-Id: <bi5232$54oud$1@ID-184292.news.uni-berlin.de>
kamal wrote:
> I need to remove $b from $a
>
> $a = "abc/\def/ghi" ;
> $b = "abc/\def";
------------^
Is that intended to be a literal \ character? Since you used
doublequotes, that's not how it is interpreted.
The direct answer to your question, already posted by Steffen, is
simple, and I'm honestly surprised that you need to ask here. Where
did you look for an answer? Did you have a problem with finding or
understanding the applicable docs?
http://www.perldoc.com/perl5.8.0/pod/perlop.html#Regexp-Quote-Like-Operators
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 22 Aug 2003 14:01:52 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: string matching
Message-Id: <u9d6exx2v3.fsf@wcl-l.bham.ac.uk>
kamal@india.ti.com (kamal) writes:
> I need to remove $b from $a
$a =~ s/\Q$b//;
(Or you can use a non-Perlish solution using substr() and index()
that'll take longer to write, be difficult to read, look less like
Perl but will probably run a little faster).
> $a = "abc/\def/ghi" ;
> $b = "abc/\def";
BTW you should always develop with warnings on. The above generates
two "Unrecognized escape \d passed through" warnings.
This looks like a homework question. The s/// operator is usually
covered quite early in any Perl course.
If this is a taught course be aware there's a fair chance your teacher
will be monitoring Usenet so you are not going to fool anyone.
If you are leaning from a book, doesn't it have answers in the back?
If you are not on a Perl course then perhaps you should be. Please do
not take offense when I say if you are at the level where you need to
ask many of this level of question you'd probably beniefit more from
some sort of structured Perl course more than you will from asking odd
isolated questions on Usenet.
(Of course, it could just be you had a mental block, in which case
disregard the above).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 22 Aug 2003 03:59:03 -0700
From: hogspog@hotmail.com (Hog Spog)
Subject: Using DBI from within Apache
Message-Id: <4ab6518c.0308220259.476852b9@posting.google.com>
Hello
Please help. I have loaded the latest DBI and DBD::Oracle modules.
These have compiled and installed successfully and I have a program
that logs into my database and works fine from the command line. This
is as long as I have the environment variables ORACLE_HOME and
LD_LIBRARY_PATH set and exported. However I cannot call the program
as a CGI program from my Apache server. My CGI directory is properly
configured in that I can call other CGI programs with no problem. I
have stopped the httpd daemon and started it again with those
environment variables set and exported but to no avail.
I get the following error in the error_log.
install_driver(Oracle) failed: Can't load
'/usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/DBD/Oracle/Oracle.so'
for module DBD:Oracle: libclntsh.so.8.0: cannot load shared object
file: No such file or directory at
/usr/lib/perl5/5.6.0/i386-linus/Dynaloader.pm line 200. at (eval 1)
line 3
The shared library libclntsh.so.8.0 exists in the directory
/home/oracle/product/8.1.6/lib which is what the LD_LIBRARY_PATH is
set to. My question is really how do I get the LD_LIBRARY_PATH set
when my CGI programs run?
Thanks in advance
Hog Spog
------------------------------
Date: 22 Aug 2003 12:36:42 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Using DBI from within Apache
Message-Id: <u9zni1x6t1.fsf@wcl-l.bham.ac.uk>
hogspog@hotmail.com (Hog Spog) writes a lot of rambing thoughts, then
finally sorts himself out and realised that:
> My question is really how do I get the LD_LIBRARY_PATH set
> when my CGI programs run?
So having got that far you should have gone back an changed the
"Newsgroups" line to point to some newsgroups where CGI and web
server (and in particular Apache) conifuration are discussed.
This newsgroup is about Perl, and as you yourself point out your
question is not about Perl.
OT Hint: The Apache conifuration directives that maniputate the
environment variables tend to have "Env" somewhere in their names.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
OA
------------------------------
Date: Fri, 22 Aug 2003 13:19:39 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Using DBI from within Apache
Message-Id: <3F460A5B.AA4A4232@oracle.com>
This is a multi-part message in MIME format.
--------------75E181E00BB6F5BEF1EEA3C7
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Brian McCauley wrote:
> hogspog@hotmail.com (Hog Spog) writes a lot of rambing thoughts, then
> finally sorts himself out and realised that:
>
> > My question is really how do I get the LD_LIBRARY_PATH set
> > when my CGI programs run?
>
> So having got that far you should have gone back an changed the
> "Newsgroups" line to point to some newsgroups where CGI and web
> server (and in particular Apache) conifuration are discussed.
>
> This newsgroup is about Perl, and as you yourself point out your
> question is not about Perl.
>
> OT Hint: The Apache conifuration directives that maniputate the
> environment variables tend to have "Env" somewhere in their names.
Wouldn't it be possible to set your LD_LIBRARY_PATH and your ORACLE_HOME
in the perl script rather than relying on the environment your "nobody"
apache user gets?
$ENV{LD_LIBRARY_PATH}="/usr/lib.....";
$ENV{ORACLE_HOME}="/oracle/ora81...";
Graham
--------------75E181E00BB6F5BEF1EEA3C7
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------75E181E00BB6F5BEF1EEA3C7--
------------------------------
Date: 22 Aug 2003 06:06:23 -0700
From: ts@relson.net (Tony)
Subject: Re: Using DBI from within Apache
Message-Id: <63073ce9.0308220506.6fe67223@posting.google.com>
hogspog@hotmail.com (Hog Spog) wrote in message news:<4ab6518c.0308220259.476852b9@posting.google.com>...
> Hello
>
> Please help. I have loaded the latest DBI and DBD::Oracle modules.
> These have compiled and installed successfully and I have a program
> that logs into my database and works fine from the command line. This
> is as long as I have the environment variables ORACLE_HOME and
> LD_LIBRARY_PATH set and exported. However I cannot call the program
> as a CGI program from my Apache server. My CGI directory is properly
> configured in that I can call other CGI programs with no problem. I
> have stopped the httpd daemon and started it again with those
> environment variables set and exported but to no avail.
> I get the following error in the error_log.
>
> install_driver(Oracle) failed: Can't load
> '/usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/DBD/Oracle/Oracle.so'
> for module DBD:Oracle: libclntsh.so.8.0: cannot load shared object
> file: No such file or directory at
> /usr/lib/perl5/5.6.0/i386-linus/Dynaloader.pm line 200. at (eval 1)
> line 3
>
> The shared library libclntsh.so.8.0 exists in the directory
> /home/oracle/product/8.1.6/lib which is what the LD_LIBRARY_PATH is
> set to. My question is really how do I get the LD_LIBRARY_PATH set
> when my CGI programs run?
>
> Thanks in advance
>
> Hog Spog
Hi,
I had a similar sort of thing, perl worked from the command line but
not in a cgi script. In the end I found it to be permissions, what
ever your web server runs as it will probably need read and execute
permissions on all libs it is trying to use.
Hope this helps
Tony
------------------------------
Date: Fri, 22 Aug 2003 13:10:18 +0200
From: Michel Rodriguez <newsguy@xmltwig.com>
Subject: Re: XML parsing problem
Message-Id: <bi4tmr$rpc$1@news-reader2.wanadoo.fr>
Kurt Klinner wrote:
> while trying to parse a "large" XML document i found a
> strange behaviour of the Parser Module(s) (XML::Parser:PerlSAX,
> XML::Parser, XML::Parser::Expat
>
> If my file XML file is larger then 65536 bytes
> the actual character string is interrupted and a whitespace
> is added.
This is documented behaviour:
in XML::Parser::Expat (I know, you have to know where to look ;--(
· Char (Parser, String)
This event is generated when non-markup is recognized. The non-
markup sequence of characters is in String. A single non-markup
sequence of characters may generate multiple calls to this han-
dler. Whatever the encoding of the string in the original docu-
ment, this is given to the handler in UTF-8.
All books or tutorials about XML::Parser show how to do this (buffer the
text in the character handler and output it when you find any other event).
If you use SAX you can use XML::Filter::BufferText (set up a pipeline using
SAX::MAchines and have an XML::Filter::BufferText object as the first
handler in the pipeline).
Incidently, I believe most SAX parsers behave that way, character handlers
can be called several times for a single element content.
__
Michel Rodriguez
Perl & XML
http://xmltwig.com
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 V10 Issue 5409
***************************************