[24351] in Perl-Users-Digest
Perl-Users Digest, Issue: 6540 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 8 00:05:55 2004
Date: Fri, 7 May 2004 21:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 7 May 2004 Volume: 10 Number: 6540
Today's topics:
$# and 2d arrays <webmaster@neverseenbefore.com>
Re: $# and 2d arrays <spamtrap@dot-app.org>
Re: $# and 2d arrays <emschwar@pobox.com>
Re: $# and 2d arrays <invalid-email@rochester.rr.com>
Re: $# and 2d arrays <webmaster@neverseenbefore.com>
Re: $# and 2d arrays <webmaster@neverseenbefore.com>
Re: $# and 2d arrays <xxala_qumsiehxx@xxyahooxx.com>
Re: $# and 2d arrays <invalid-email@rochester.rr.com>
Re: a simple RegExp question <matthew.garrish@sympatico.ca>
Re: a simple RegExp question <abigail@abigail.nl>
Re: Books online???? (Anno Siegel)
Re: Converting a string into hex chars? (Jay Tilton)
Re: free source authentication script <jtc@shell.dimensional.com>
Re: Help Needed Building Array Of Hashes From CSV <jtc@shell.dimensional.com>
Re: How to redirect STDOUT to a string? <usenet@morrow.me.uk>
Re: How to redirect STDOUT to a string? <krahnj@acm.org>
How to use two or more question in function if ? <tamara@agencija.com>
Re: How to use two or more question in function if ? <nospam@bigpond.com>
Re: is there something more elegant to convert Dos to u (Andrew)
Re: newbie; appending multiple files <lv@aol.com>
Re: Perl DBI and DB2 Stored Procedure <ianbjor@mobileaudio.com>
Re: Perl script runs from command prompt but not from T <usenet@morrow.me.uk>
Re: read from comma delimited file <jtc@shell.dimensional.com>
Re: read is blocking on win32 CGI <matthew.garrish@sympatico.ca>
Re: regex utility <thepoet_nospam@arcor.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 8 May 2004 03:10:20 +0200
From: "Dieter D'Hoker" <webmaster@neverseenbefore.com>
Subject: $# and 2d arrays
Message-Id: <2g2qbsF3q4emU1@uni-berlin.de>
quick questions,
if i have an aray @array that i'm going to fill :
for (my $y=0; $y<20; $y++) {
for (my $x=0; $x<20; $x++) {
$field[$x][$y] = 0;
}
}
should i use $#array = 19;
or $#array = 399; ?
to predefine the correct lenght ?
--
Dieter D'Hoker
news:free.nl.dieter.dhoker & news:alt.nl.fan.dieter.dhoker
Google? http://neverseenbefore.com/
Multiplayer tetris? http://www.tsrv.com/
------------------------------
Date: Fri, 07 May 2004 21:27:07 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: $# and 2d arrays
Message-Id: <AqidnaoEZIPxqgHd4p2dnA@adelphia.com>
Dieter D'Hoker wrote:
> if i have an aray @array that i'm going to fill :
>
> should i use $#array = 19;
> or $#array = 399; ?
> to predefine the correct lenght ?
What leads you to think you need to predefine the length of an array at all?
This is Perl, not C. Just assign the values you want to the array elements
- the array will take care of itself, resizing as needed.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Fri, 07 May 2004 19:28:15 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: $# and 2d arrays
Message-Id: <etollk3g11s.fsf@fc.hp.com>
"Dieter D'Hoker" <webmaster@neverseenbefore.com> writes:
> if i have an aray @array that i'm going to fill :
>
> for (my $y=0; $y<20; $y++) {
> for (my $x=0; $x<20; $x++) {
> $field[$x][$y] = 0;
> }
> }
Two problems:
1) You're referring to @field here, not @array. Which is it?
2) C-style loops are ugly. Assuming you are going to do
something like this, try a more Perlish approach:
foreach my $x (0..19) {
foreach my $y (0..19) {
$field[$x][$y] = 0;
}
}
> should i use $#array = 19;
> or $#array = 399; ?
> to predefine the correct lenght ?
The answer is neither, as a rule. Why do you feel you need to
predefine the length of the array at all? I suppose if you had
several thousand entries it might make sense, but for the example you
posted, it's a waste of time. So far, I have never written a program
in Perl that would benefit significantly from preallocating arrays,
and I've been coding in Perl for about 7 years now.
That said, if you absolutely feel you must, and I emphasize again that
you probably do not need to do this, the answer lies in what a '2d
array' really is in Perl: an array of arrayrefs. So the top-level
array only should be predefined to have as many entries in it as $x
will index.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Sat, 08 May 2004 01:41:26 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: $# and 2d arrays
Message-Id: <409C3AC0.4050402@rochester.rr.com>
Dieter D'Hoker wrote:
...
> if i have an aray @array that i'm going to fill :
field?---------------^^^^^
You used the variable @field in your example below??
>
> for (my $y=0; $y<20; $y++) {
> for (my $x=0; $x<20; $x++) {
> $field[$x][$y] = 0;
> }
> }
>
> should i use $#array = 19;
field?-----------^^^^^
> or $#array = 399; ?
field?-^^^^^
> to predefine the correct lenght ?
>
>
Well, Perl's "2D" arrays are really a set of 1D arrays. The "outer"
array contains references to a set of "inner" anonymous (i.e., nameless)
arrays. So you should use $#field=19; in your example above, if that is
what you want to do (there probably actually is *very* little point to
predefining the array). But if you are going to do that, you should
also predefine the inner arrays as well. But the code you have will
store the 0th element of each of the 20 inner arrays, then the 1st
element, etc. So your outer for loop should be on $x rather than $y if
you want to do that without adding another loop. Something like:
my @field;
$#field=19; #predefine length of outer array @field
for my $x (0..19){
$#{$field[$x]}=19; #predefine length of anonymous array
for my $y (0..19){
$field[$x][$y]=0;
}
}
But again, there is probably not much point in predefining the array length.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sat, 8 May 2004 04:31:54 +0200
From: "Dieter D'Hoker" <webmaster@neverseenbefore.com>
Subject: Re: $# and 2d arrays
Message-Id: <2g2v4qF3qdofU1@uni-berlin.de>
Bob Walton wrote:
> my @field;
> $#field=19; #predefine length of outer array @field
> for my $x (0..19){
> $#{$field[$x]}=19; #predefine length of anonymous array
> for my $y (0..19){
> $field[$x][$y]=0;
> }
> }
>
> But again, there is probably not much point in predefining the array
> length.
okay thx for the response,
sorry for the mixup between @field and @array, i was typing the message when
i saw i got the code open on my other screen and just copy paste it :)
well, i have made an AI that has to make 1000's of those fields and evaluate
them within a least every second,
but the more it can do the better ... So i thought predifining the arrays
might give it a little edge ?
--
Dieter D'Hoker
news:free.nl.dieter.dhoker & news:alt.nl.fan.dieter.dhoker
Google? http://neverseenbefore.com/
Multiplayer tetris? http://www.tsrv.com/
------------------------------
Date: Sat, 8 May 2004 04:47:08 +0200
From: "Dieter D'Hoker" <webmaster@neverseenbefore.com>
Subject: Re: $# and 2d arrays
Message-Id: <2g301cF3pas0U1@uni-berlin.de>
Eric Schwartz wrote:
> "Dieter D'Hoker" <webmaster@neverseenbefore.com> writes:
>> if i have an aray @array that i'm going to fill :
>>
>> for (my $y=0; $y<20; $y++) {
>> for (my $x=0; $x<20; $x++) {
>> $field[$x][$y] = 0;
>> }
>> }
>
> Two problems:
>
> 1) You're referring to @field here, not @array. Which is it?
i made a mistake @field = @array , sorry for the mixup
>
> 2) C-style loops are ugly. Assuming you are going to do
> something like this, try a more Perlish approach:
>
> foreach my $x (0..19) {
> foreach my $y (0..19) {
> $field[$x][$y] = 0;
> }
> }
besides being less ugly, is this also faster ?
>> should i use $#array = 19;
>> or $#array = 399; ?
>> to predefine the correct lenght ?
>
> The answer is neither, as a rule. Why do you feel you need to
> predefine the length of the array at all? I suppose if you had
> several thousand entries it might make sense, but for the example you
> posted, it's a waste of time. So far, I have never written a program
> in Perl that would benefit significantly from preallocating arrays,
> and I've been coding in Perl for about 7 years now.
well i have an AI that tries to find the best move on a 20*20 field,
therefore it tries all possible moves and evaluates the resulting field,
this results in about 48 fields that are created,
but to make it smarter it then tries to lookahead every 48 fields result in
another 48 fields ,
resulting in 2304 fields, etc. And all this has to be done in realtime, the
AI has to give a response within very little time.
So i'm trying to optimize the code wherever possible, ..
--
Dieter D'Hoker
news:free.nl.dieter.dhoker & news:alt.nl.fan.dieter.dhoker
Google? http://neverseenbefore.com/
Multiplayer tetris? http://www.tsrv.com/
------------------------------
Date: Sat, 08 May 2004 02:53:41 GMT
From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: $# and 2d arrays
Message-Id: <VYXmc.6421$x84.3107@newssvr27.news.prodigy.com>
Dieter D'Hoker wrote:
> quick questions,
>
> if i have an aray @array that i'm going to fill :
>
> for (my $y=0; $y<20; $y++) {
> for (my $x=0; $x<20; $x++) {
> $field[$x][$y] = 0;
> }
> }
>
> should i use $#array = 19;
> or $#array = 399; ?
> to predefine the correct lenght ?
Neither. Generally, you don't need to, but if you had to initialize
everything to 0 (if undef is not good enough) then I would suspect that
the following would be faster:
my @field;
$field[$_] = [(0) x 20] for 0 .. 19;
I didn't benchmark though.
--Ala
------------------------------
Date: Sat, 08 May 2004 02:56:23 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: $# and 2d arrays
Message-Id: <409C4C50.5080301@rochester.rr.com>
Dieter D'Hoker wrote:
> Bob Walton wrote:
>
>
>> my @field;
>> $#field=19; #predefine length of outer array @field
>> for my $x (0..19){
>> $#{$field[$x]}=19; #predefine length of anonymous array
>> for my $y (0..19){
>> $field[$x][$y]=0;
>> }
>> }
>>
>>But again, there is probably not much point in predefining the array
>>length.
>>
>
> okay thx for the response,
> sorry for the mixup between @field and @array, i was typing the message when
> i saw i got the code open on my other screen and just copy paste it :)
Copy/paste is *definitely* the way to do it. Code is bad enough without
typos.
>
> well, i have made an AI that has to make 1000's of those fields and evaluate
> them within a least every second,
> but the more it can do the better ... So i thought predifining the arrays
> might give it a little edge ?
Yeah, maybe. You could
use Benchmark;
to find out. But if you're that concerned about speed, you probably
want to use C or Fortran instead of Perl.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Fri, 7 May 2004 18:05:21 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: a simple RegExp question
Message-Id: <xKTmc.47576$3Q4.1200996@news20.bellglobal.com>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2g2bo7F3rb9iU1@uni-berlin.de...
> S. Levent Yilmaz wrote:
> > Find all lines which contain a given word (say 'kitty') not
> > preceded with another given word (say 'puppy') . For instance:
> >
> > I have two pets:
> > my kitty is very cute
> > but puppy is cuter than kitty
> >
> > What regular expression stands only for the 2nd line? Note that the
> > other way around is very easy, that is the lines with 'puppy'
> > followed by 'kitty' is only "puppy.*kitty"
> > Is this possible at all with a single RegExp?
>
> Don't know, but why not just do:
>
> /\bkitty\b/ and !/\bpuppy\b.*\bkitty\b/
>
Or if the OP had bothered to read a bit of perlre:
/\bkitty\b/ and $` !~ /\bpuppy\b/
Matt
------------------------------
Date: 07 May 2004 23:15:47 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: a simple RegExp question
Message-Id: <slrnc9o653.egl.abigail@alexandra.abigail.nl>
S. Levent Yilmaz (sly5@pitt.edu) wrote on MMMCMII September MCMXCIII in
<URL:news:c7gs2a$n9e$1@usenet01.srv.cis.pitt.edu>:
\\ Hello,
\\
\\ It sounded like a very simple problem but I couldn't come up with an
\\ elegant solution. The problem is:
\\
\\ Find all lines which contain a given word (say 'kitty') not preceded
\\ with another given word (say 'puppy') . For instance:
\\
\\ I have two pets:
\\ my kitty is very cute
\\ but puppy is cuter than kitty
\\
\\ What regular expression stands only for the 2nd line? Note that the
\\ other way around is very easy, that is the lines with 'puppy' followed
\\ by 'kitty' is only "puppy.*kitty"
\\ Is this possible at all with a single RegExp?
Not to hard. The only issue is where to sit between the extremes of
simplicity and speed. I usually settle for one level of unrolling,
and I'd go for:
/^[^p]*(?:p(?!uppy)[^p]*)*kitty/
But you could fully eliminate the (?!uppy) for more speed.
Abigail
--
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
------------------------------
Date: 7 May 2004 23:58:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Books online????
Message-Id: <c7h7r5$qoo$1@mamenchi.zrz.TU-Berlin.DE>
taswold <hen_mcgiggle@yahoo.co.uk> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> [file under depressing predictions come true]
I don't see how that follows from my reply, except by reading into it
what isn't in it. Been nice talking to you...
Anno
------------------------------
Date: Sat, 08 May 2004 02:53:06 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Converting a string into hex chars?
Message-Id: <409c4b5a.16364410@news.erols.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
: Eric wrote:
: > I need to convert a string into a HTML encoded hex equivalent.
: See the sprintf() function.
:
: $encmsg .= sprintf '%%%02X', ord $_ for split //, $message;
Or even let sprintf() do every bit of the work.
my $encmsg = sprintf "%%%*v02X", '%', $message;
------------------------------
Date: 7 May 2004 18:47:46 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: free source authentication script
Message-Id: <slrnc9obhj.5ej.jtc@shell.dimensional.com>
In article <slrnc9nsaa.99i.spamtotrash@doom.unix-guy.com>, Kevin Collins wrote:
> In article <c7e9l0$72c$1@reader2.nmix.net>, Robin wrote:
> -snip-
>>
>> I might be an idiot, but not a stupid one.
>> -Robin
>
> That is one of the funniest things I have seen in a long time :)
Reminds me of a novel by Dostoevsky.
--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
------------------------------
Date: 7 May 2004 18:55:22 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: Help Needed Building Array Of Hashes From CSV
Message-Id: <slrnc9obvr.5ej.jtc@shell.dimensional.com>
In article <yawmc.32533$IG1.1638085@attbi_s04>, Tim Sheets wrote:
> Jim Cochrane wrote:
>
>
>> Sorry, Tim - I was probably being a little overly didactic, but I was
>> trying to point out that you didn't really say why you are trying to build
>> an array of hashes - that is, what you were going to do with the array
>> once you built it. In other words, often if you can specify a problem
>> from what the program should do from the perspective of a user of the
>> program who has no idea of what the code looks like, you can be clear
>> as to what the problem actually is, both in terms of your own thinking
>> and for presenting it to others. Often this helps not only in finding
>> a correct implementation, but in finding a better one (e.g., more efficient,
>> easier to maintain, or etc.)
>
> Thanks for the clarification, Jim. I will keep this in mind in future
> posts.
You're welcome. I think Eric Bohlman did a good job of clarifying the
issue further in his post. You might want to read it if you haven't
already.
>
>> I do maintain that to become truly good at programming, it's necessary
>> to be able to state a problem without mentioning or implying an
>> implementation (e.g., without talking about hashes, arrays, etc.).
>> However, becoming a professional programmer may not be your goal, which is
>> why I was perhaps being overly didactic.
>
> While I would like to be a great programmer, it isn't my primary
> function at work, and don't really want to be a programmer by
> profession. The way I tell it is "I want to know enough programming to
> be able to do what I want to do". :-) Of course that may change from
> day to day... So, I end up writing a little script to accomplish a
> specific task about once every 3 or 4 months.
I understand. And that's a very reasonable goal.
> Anyway, thanks again for the pointers on posting questions from the
> perspective of the problem, and what I am trying to accomplish, as
> opposed to an implementation perspective.
IMO, if you put some effort into learning better how to do this, it will
give you a useful edge.
--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
------------------------------
Date: Fri, 7 May 2004 22:56:28 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: How to redirect STDOUT to a string?
Message-Id: <c7h46s$53k$4@wisteria.csv.warwick.ac.uk>
Quoth J Krugman <jkrugman@yahbitoo.com>:
> One related question: is there a way to get the currently selected
> filehandle without using select (and therefore deselecting it)? (I
> thought that this would be stuck in some Perl variable, but I can't
> find it in the perlvar manpage.)
Howabout
my $FH = select STDOUT;
select $FH;
? Unselecting and then reselecting a FH has no effect (you do need to be
sure that STDOUT will be open though, which *ought* to always be
safe...).
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: Sat, 08 May 2004 03:27:05 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to redirect STDOUT to a string?
Message-Id: <409C5387.BB46058A@acm.org>
J Krugman wrote:
>
> One related question: is there a way to get the currently selected
> filehandle without using select (and therefore deselecting it)? (I
> thought that this would be stuck in some Perl variable, but I can't
> find it in the perlvar manpage.)
select with no arguments will return the currently selected filehandle.
use POSIX qw( STDOUT_FILENO );
if ( STDOUT_FILENO == fileno( select ) ) {
print "The current default filehandle is STDOUT.\n";
}
> And one more: can someone point me to where in the Perl documentation
> lexical filehandles are discussed?
In perldata under the "Typeglobs and Filehandles" section.
perldoc perldata
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 8 May 2004 05:28:25 +0200
From: "Tamara" <tamara@agencija.com>
Subject: How to use two or more question in function if ?
Message-Id: <c7hk5e$odu$1@ls219.htnet.hr>
How to use two or more question in function if ?
E.g.
If a=0 and b=20 then print "a=o and b=20"
------------------------------
Date: Sat, 08 May 2004 13:47:50 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: How to use two or more question in function if ?
Message-Id: <1971475.5HOhMMrlRK@GMT-hosting-and-pickle-farming>
Tamara wrote:
> How to use two or more question in function if ?
> E.g.
> If a=0 and b=20 then print "a=o and b=20"
print "a=0 and b=20" if $a==0 && $b==20
gtoomey
------------------------------
Date: 7 May 2004 21:00:50 -0700
From: myfam@surfeu.fi (Andrew)
Subject: Re: is there something more elegant to convert Dos to unix in subroutine?
Message-Id: <c5826e91.0405072000.708b9fd4@posting.google.com>
Thanks for constructive remarks, here is the fixed one, which, again,
works just fine :)
#
# Converts DOS to UNIX file
# if trim is true will trim leading and trailing spaces and remove
empty lines
#
sub toUnixFile {
my ($file, $trim) = @_;
-f $file || die "Can't open \"$file\": $! \n";
my $temp_file = $file . ".tmp.$$.$^T";
move($file, $temp_file);
local *in;
local *out;
open(in, "<$temp_file");
open(out, ">$file");
while(<in>) {
chomp;
s/\r$//;
if ($trim eq "true") {
s/^\s*//;
s/\s*$//;
unless ( -z $_ ) {
print out "$_\n";
}
} else {
print out "$_\n";
}
}
close in;
close out;
unlink $temp_file;
}
Uri Guttman <uri@stemsystems.com> wrote in message news:<x7zn8ptes0.fsf@mail.sysarch.com>...
> >>>>> "A" == Andrew <myfam@surfeu.fi> writes:
>
> A> Hm, my subroutine is actually working just fine, prove me wrong, it
> A> conversts DOS files to UNIX just fine.
>
> it has several bugs.
>
> A> All examples given involve calling perl from code, I don't like it, I
> A> would like a subroutine or function which can be included in my perl
> A> code. I don't like calling perl from perl.
>
> huh? what calling perl from code are you talking about? the answers were
> all one liners and it is trivial to convert any of them to a sub.
>
> >> >
> >> > sub toUnixFile() {
> >> > my ($file) = @_;
> >> > my ($temp_file) = $file . ".tmp";
>
> and what if that file already existed?
>
> >> > move($file, $temp_file);
> >> > open(in, "<$temp_file");
> >> > open(out, ">$file");
>
> and what if either of those open calls fails?
>
> >> > while(<in>) {
> >> > chomp;
> >> > ~ s/\r$//;
>
> what is that naked ~ doing there?
>
> >> > print out "$_\n";
> >> > }
> >> > close in;
> >> > close out;
> >> > unlink $temp_file;
> >> > return 0;
>
> why the return 0? you don't return from anywhere else.
>
> so your sub it not 'actually working just fine'. proving it wrong was
> too easy. you just didn't get the answers.
>
> now fix your sub and use the ideas shown and post new code. you have to
> do some of the work too.
>
> uri
------------------------------
Date: Fri, 07 May 2004 21:30:50 -0500
From: l v <lv@aol.com>
Subject: Re: newbie; appending multiple files
Message-Id: <409c468c_1@corp.newsgroups.com>
David K. Wall wrote:
> Ian Wilson <scobloke2@infotop.co.uk> wrote:
>
>
>>And 'print while <>' is the -p option ...
>>
>>$ echo xxx > bulk.txt
>>$ echo aaa > 1.txt
>>$ echo bbb > 2.txt
>>$ echo ccc > 3.txt
>>$ perl -pe "" ?.txt >> bulk.txt
>>$ cat bulk.txt
>>xxx
>>aaa
>>bbb
>>ccc
>>
>>I suppose this *might* be useful on a platform that has perl but
>>lacks cat or a decent shell?
>
>
> Sure, but even in later versions of DOS (at least v3+, IIRC) you
> could use
>
> C:\> for %f in (?.txt) do type %f >> bulk.txt
>
> and under win2k at least, 'type ?.txt > bulk.txt' seems to work as
> you might expect. The DOS shell is not completely brain-dead, just
> mentally retarded. :-)
>
> Not that this has anything remotely to do with Perl...
In dos I've used 'copy *.txt bulk.txt' without any problems
Len
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
------------------------------
Date: Fri, 07 May 2004 15:45:46 -0700
From: Ian <ianbjor@mobileaudio.com>
Subject: Re: Perl DBI and DB2 Stored Procedure
Message-Id: <409c120e$1_1@corp.newsgroups.com>
Wonderinguy wrote:
> Hi everybody , I have been trying to execute a simple DB2 stored
> Procedure from perl. But it doesn't work. Could anybody please help me
> find out why this is happening :
>
> [Fri May 07 15:14:56 2004] [error] [client 127.0.0.1] DBD::DB2::st
> execute failed: [IBM][CLI Driver][DB2] SQL0440N No function by the
> name "SPACESP" having compatible arguments was found in the function
> path. SQLSTATE=42884
>
The problem is that you're passing VARCHAR datatypes, and your stored
procedure is defined with some other data type (probably CHAR). The
constant string 'DB' is varchar(2)
This is not related to perl, DBI or DBD::DB2.
You have 2 options:
$callstmt = "CALL SPACESP(CHAR('DB'), CHAR('TEXAS'))";
or (better, using parameter markers, since you can re-use the statement
handle if you call the stored proc multiple times):
$p1 = "DB";
$p2 = "TEXAS";
$callstmt = "CALL SPACESP(?, ?)";
$sth = $dbh->prepare($callstmt);
$sth->execute($p1, $p2);
Good luck,
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
------------------------------
Date: Fri, 7 May 2004 22:44:15 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Perl script runs from command prompt but not from Task Scheduler in Win2000
Message-Id: <c7h3fu$53k$3@wisteria.csv.warwick.ac.uk>
Quoth kpowell10@hotmail.com (kpowell10):
> Hi all,
>
> I have a script that runs fine from the command prompt, but that fails
> when I run it from Task Scheduler.
>
> Apparently the line that is failing is an OLE module command:
> $xlworkbook = $xl_app->Workbooks->Add;
>
> Any ideas what might cause this behavior or how to pin down the cause?
You probably don't have Excel running when the task is scheduled. IIRC
there is an OLE call that will create a new instance of
Excel.Application, or return a running one if there is one...?
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
ben@morrow.me.uk The Levellers, 'Believers'
------------------------------
Date: 7 May 2004 19:04:59 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: read from comma delimited file
Message-Id: <slrnc9ocht.5ej.jtc@shell.dimensional.com>
In article <slrnc9n9cf.irt.xx087@smeagol.ncf.ca>, Glenn Jackman wrote:
> Jim Cochrane <jtc@shell.dimensional.com> wrote:
>> Yes, but it appears to be harder with split, because you can't use (...)
>> grouping without affecting the result of the split. I just learned about
>> this while playing around with another problem last night.
>
> Sure you can. Just use non-capturing parentheses (?:my regex)
OK - I just learned something new and useful.
Thanks!
--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
------------------------------
Date: Fri, 7 May 2004 18:15:30 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: read is blocking on win32 CGI
Message-Id: <3UTmc.47595$3Q4.1202043@news20.bellglobal.com>
"William" <gwshieh@hotmail.com> wrote in message
news:5f261ebe.0405070539.4fada625@posting.google.com...
> Hi,
>
> I'm working on a CGI which invoked by IIS6.0. However, in the cgi perl
> script, i have a read which should read all POST content. I found 2
> things interesting
>
> 1. the read becomes blocking if I want to read more than it was
> submitted
> 2. the $ENV{'CONTENT_LENGTH'} is not reliable. In my case, the content
> is 16330 bytes but it tells me 16600.
>
Let me guess, is the file 271 lines long?
Are you using CGI.pm? If not, you should be...
Matt
------------------------------
Date: Sat, 8 May 2004 01:45:41 +0200
From: "Christian Winter" <thepoet_nospam@arcor.de>
Subject: Re: regex utility
Message-Id: <409c2011$0$10902$9b4e6d93@newsread2.arcor-online.net>
"Chris Mattern" wrote:
> Christian Winter wrote:
[...]
> > my $c;
> > print "match ",++$c,": $_$/" for($ARGV[1]=~m($ARGV[0])g);
> >
> Such a lovely day for golf, isn't it?
Indeed it is. To be honest, I'm already suffering
withdrawal because I didn't find the time to
participate in terje's last one and fwp isn't
really overcrowded nowadays. But lets get the
score up: ;-)
print"match ",++$c,": $_$/"for(pop)=~/@ARGV/g;
-Christian
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6540
***************************************