[15508] in Perl-Users-Digest
Perl-Users Digest, Issue: 2918 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 1 21:05:20 2000
Date: Mon, 1 May 2000 18:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957229509-v9-i2918@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 1 May 2000 Volume: 9 Number: 2918
Today's topics:
array searching <ascii7@home.com>
Re: array searching <lr@hpl.hp.com>
Re: array searching <Jonathan.L.Ericson@jpl.nasa.gov>
Re: DBI Installation Win2K reedjd@bitsmart.com
EZ: How do I check if a value exists in an array? <nickysantoro@yahoo.com>
Re: EZ: How do I check if a value exists in an array? (Jerome O'Neil)
Re: EZ: How do I check if a value exists in an array? <lr@hpl.hp.com>
Re: EZ: How do I check if a value exists in an array? <Jonathan.L.Ericson@jpl.nasa.gov>
Re: filehandles, forking, and alpha-dec_osf nwhite210@my-deja.com
Passing DBI Connection between Processes? reedjd@bitsmart.com
Re: Please Explain ... print "Location: http:etc."; <care227@attglobal.net>
Problem with $ sign in string otrcomm@wildapache.net
Re: Problem with $ sign in string <news**NO_SPAM**@psychogenic.com>
Re: Problem with $ sign in string (Kim Saunders)
Re: Problem with $ sign in string <lr@hpl.hp.com>
Re: Problem with $ sign in string <Jonathan.L.Ericson@jpl.nasa.gov>
resizing an image <vioon@hotmil.com>
Re: setting an array in a Struct? <lr@hpl.hp.com>
Re: setting an array in a Struct? <Jonathan.L.Ericson@jpl.nasa.gov>
Re: setting an array in a Struct? <lr@hpl.hp.com>
Re: subroutines in perl4 <makarand_kulkarni@My-Deja.com>
Re: Upgrading Perl <ar.zeini@REMOVEuni-koeln.de>
Re: VMS Perl system() truncating lines <lr@hpl.hp.com>
Re: which subs are defined <lr@hpl.hp.com>
Re: Win98 Pipe problem <Jonathan.L.Ericson@jpl.nasa.gov>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 01 May 2000 22:52:36 GMT
From: ascii7 <ascii7@home.com>
Subject: array searching
Message-Id: <390C8814.F97E8624@home.com>
I am learning Perl and was wondering if you could help me with a
problem. I want to know if there is a way to pass the grep function a
variable. Ex:
@an_array=grep /$a_string/, @another_array;
Where $a_string is user input. Any help would be appreciated.
------------------------------
Date: Mon, 1 May 2000 16:16:12 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: array searching
Message-Id: <MPG.1377b018607ab55f98a9c6@nntp.hpl.hp.com>
In article <390C8814.F97E8624@home.com> on Mon, 01 May 2000 22:52:36
GMT, ascii7 <ascii7@home.com> says...
> I am learning Perl and was wondering if you could help me with a
> problem. I want to know if there is a way to pass the grep function a
> variable. Ex:
>
> @an_array=grep /$a_string/, @another_array;
>
> Where $a_string is user input. Any help would be appreciated.
What happened when you tried it?
Warning: You must decide if the user input is a literal string or a
regex. If the former, you should interpolate it thus:
/\Q$a_string/
Or you might use a different predicate, such as a comparison operator or
the index() function, to decide if the match occurs.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 01 May 2000 16:13:22 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: array searching
Message-Id: <390E0F92.4DF123AA@jpl.nasa.gov>
ascii7 wrote:
> I am learning Perl and was wondering if you could help me with a
> problem. I want to know if there is a way to pass the grep function a
> variable. Ex:
>
> @an_array=grep /$a_string/, @another_array;
>
> Where $a_string is user input. Any help would be appreciated.
Umm... did you try it?
bash$ perl -e '$a = q(100); print grep /$a/, localtime'
100
A simple test would have taken and wasted less time than writing this
post and waiting for an answer.
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: Tue, 02 May 2000 00:37:58 GMT
From: reedjd@bitsmart.com
Subject: Re: DBI Installation Win2K
Message-Id: <8el815$emt$1@nnrp1.deja.com>
If you're running Perl 5.005 you should find
c:\Perl\bin\ppm.bat
This is a package manager for Perl. Run it, because it makes
installing packages easy! You'll probably just need to type:
install DBI
while connected to the internet and it'll download and install the
proper packages for your system to use it. It what I used to get my
DBI working.
-jr
And you should be set to go.
In article <cdfP4.12519$x4.460079@newsread1.prod.itd.earthlink.net>,
"Fred" <fred@fred.com> wrote:
> Hi, someone please help me install DBI on my server. I've tried
multiple
> times, with no luck.
>
> There has to be an easy way to do this, but so far I haven't found
this.
> I've searched now for many hours and have finally given up on finding
the
> answer myself. The help would be greatly appreciated.
>
> I've tried using nmake and dmake but they both return errors. I also
tried
>
> perl -MCPAN -e 'install Bundle::DBD::Informix'
>
> No luck there either.
>
> If I can't get this to work I'm going to have to turn to Visual Basic,
> something I don't want to do.
>
> Thanks in Advance.
>
> John
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 1 May 2000 23:46:10 GMT
From: Nick <nickysantoro@yahoo.com>
Subject: EZ: How do I check if a value exists in an array?
Message-Id: <8el502$6u2$1@agate.berkeley.edu>
Sorry if this is basic, but I am a leisure Perl programmer. Anyway,
what can I use to check whether a value exists in an array or not (
basically returning true if it does, false if not)? Is there a built-in
function?
Thanks for any help.
------------------------------
Date: Tue, 02 May 2000 00:32:50 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: EZ: How do I check if a value exists in an array?
Message-Id: <SmpP4.459$eO6.38230@news.uswest.net>
In article <8el502$6u2$1@agate.berkeley.edu>,
Nick <nickysantoro@yahoo.com> writes:
> Sorry if this is basic, but I am a leisure Perl programmer. Anyway,
> what can I use to check whether a value exists in an array or not (
> basically returning true if it does, false if not)? Is there a built-in
> function?
Yes, but if the goal is "searching," you might consider putting your
data into a hash structure.
grep in a scalar context will return the number of times the
expression was true, but the drawback is having to iterate over
the entire array. I believe there is some expression magic
that can be worked on newer perl's to stop at the first match,
but I don't fully grok it, yet.
perldoc -f grep
You could populate a hash's keys with the values of your list using
a slice, and then use exists to check if your value is there.
This is my prefered method.
my %hash;
my @list = qw{fee fie fo fum};
@hash{@list} = ();
if(exists $hash{'fee'}){
# etc...
}
HTH!
------------------------------
Date: Mon, 1 May 2000 17:24:35 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: EZ: How do I check if a value exists in an array?
Message-Id: <MPG.1377c021b642f29b98a9c8@nntp.hpl.hp.com>
In article <8el502$6u2$1@agate.berkeley.edu> on 1 May 2000 23:46:10 GMT,
Nick <nickysantoro@yahoo.com> says...
> Sorry if this is basic, but I am a leisure Perl programmer. Anyway,
> what can I use to check whether a value exists in an array or not (
> basically returning true if it does, false if not)? Is there a built-in
> function?
There is a FAQ. Even a leisure Perl programmer should read the FAQ,
instead of hoping we will read it for you.
perlfaq4: "How can I tell whether a list or array contains a certain
element?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 01 May 2000 17:21:45 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: EZ: How do I check if a value exists in an array?
Message-Id: <390E1F99.B2FDAE22@jpl.nasa.gov>
Nick wrote:
> Sorry if this is basic, but I am a leisure Perl programmer. Anyway,
> what can I use to check whether a value exists in an array or not (
> basically returning true if it does, false if not)? Is there a built-in
> function?
From perldelta (v5.6.0):
exists() and delete() are supported on array elements
The exists() and delete() builtins now work on simple arrays as well.
The behavior is similar to that on hash elements.
exists() can be used to check whether an array element has been
initialized.
This avoids autovivifying array elements that don't exist. If the
array is
tied, the EXISTS() method in the corresponding tied package will be
invoked.
...
Could be a reason to upgrade.
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: Mon, 01 May 2000 21:58:24 GMT
From: nwhite210@my-deja.com
Subject: Re: filehandles, forking, and alpha-dec_osf
Message-Id: <8ekuln$4a8$1@nnrp1.deja.com>
In article <8eb2qj$mbc$1@nnrp1.deja.com>,
nwhite210@my-deja.com wrote:
After my previous post, I noticed that the problem was intermittent.
It can be made more consistent by having the parent process sleep
for a bit - like 2 seconds or so...See the additional line below.
Any comments?
>
>
> I'm having some difficulty using fork with open filehandles
> on alpha machines. It seems that a fork() on an alpha machine
> confuses the state of any open filehandles in the parent
> process. I've written a little program that illustrates
> the problem:
>
> #!/usr/local/bin/perl -w
>
> open( FILE, "file" ) or die "Couldn't open file\n";
>
> while( <FILE> ){
> chomp $_;
> if ( $pid = fork() ){
> # PARENT PROCESS
> print STDERR "reading line $. = $_\n";
> }
> elsif ( defined $pid ){
> # CHILD PROCESS
> close FILE or die "Couldn't close FILE\n";
> exit( 0 );
> }
> else{
> die "Couldn't fork\n";
> }
sleep 2; ############### ADD THIS LINE ###############
> }
>
> where "file" is
> line1
> line2
> line3
> line4
>
> Now, on a linux machine running perl 5.005_03 for i386-linux, the
> results are as expected:
> reading line 1 = line1
> reading line 2 = line2
> reading line 3 = line3
> reading line 4 = line4
>
> On an OSF1 v4.0 1229 alpha running perl 5.005_03 for alpha-dec_osf,
> I get:
> reading line 1 = line1
> reading line 2 = line2
> reading line 3 = line3
> reading line 4 = line4
> reading line 5 = line1
> reading line 6 = line2
> reading line 7 = line3
> reading line 8 = line4
> reading line 9 = line1
> reading line 10 = line2
> reading line 11 = line3
> reading line 12 = line4
> ...
> (infinite loop)
>
> This program illustrates how the filehandle gets confused
> but does not illustrate intermittent data corruption from
> the open filehandle, which I've experienced.
>
> Is this a bug with 5.005_03 for alpha-dec_osf?
>
> My apologizes if this question has been answered recently.
> My search for a similar post yielded 1 hit with no reply:
>
http://x44.deja.com/[ST_rn=ps]/getdoc.xp?AN=477485997&CONTEXT=956886684.
> 385089536&hitnum=75
>
> Regards,
> Neill
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 02 May 2000 00:29:34 GMT
From: reedjd@bitsmart.com
Subject: Passing DBI Connection between Processes?
Message-Id: <8el7gt$e9t$1@nnrp1.deja.com>
I have a system running where a lot of various perl processes are
starting up and stopping (web server, custom apps, etc.) and all of
them need a DBI connection to my database.
I've noticed, especially on the CGI's, that the initial creation of the
database connection slows load time down significantly.
I've been reading up on interprocess communication, but can't find an
answer to this question:
Is it possible to have a single process running with an open database
connection that can then pass that connection to other processes on
request? How would I do it?
-jordan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 01 May 2000 19:10:25 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Please Explain ... print "Location: http:etc.";
Message-Id: <390E0EE1.E9E6E2E6@attglobal.net>
"Randal L. Schwartz" wrote:
>
> I think Alan's making a good point. Alan knows what he knows, and
> knows when he doesn't know, and knows enough to shut up on the latter.
>
> There are many others here (do I need to name names and aliases? :)
> that don't know when they don't know, and speak anyway. Thus, Alan
> comes out looking like a saint, and the others, well, you get the
> drift.
Is that one still around?
>
> Me, I'm somewhere in the middle. Most of the time when I'm confident,
> I speak with authority, and am occasionally wrong (and accept
> corrections gladly). Sometimes, when I'm guessing, I guess right, but
> I at least label it a guess. Occasionally, when I think I don't have
> a clue, I give it a whack anyway, and turn out fine, or at least learn
> something in the process.
And you write good books. Im churning through the stack as I type =)
------------------------------
Date: Tue, 02 May 2000 00:01:31 GMT
From: otrcomm@wildapache.net
Subject: Problem with $ sign in string
Message-Id: <390e17b8.936638725@news.wildapache.net>
Hello,
I have a problem that I can not figure out.
I have a string variable $pointer1->{'shipping'} that evaluates to
"UPS Ground - $20.62" (minus the quotation marks)
and I want to pick the number 20.62 out of it
The $ sign is getting in the way of everything that I try.
If I try:
$shipping_string =~ s/\$//;
and print out the results, then I get
"Shipping String = UPS Ground - .62"
I have tried it with s/\$//o and the same results.
I have tried quotemeta(), and that does not work.
I realize that this is probably basic stuff, but I am stumped!
How can I pick the number 20.62 out of this string variable?
Thanks,
Murrah Boswell
otrcomm@wildapache.net
------------------------------
Date: Mon, 01 May 2000 23:55:52 GMT
From: Pat <news**NO_SPAM**@psychogenic.com>
Subject: Re: Problem with $ sign in string
Message-Id: <390E194B.4774102C@psychogenic.com>
Hi.
otrcomm@wildapache.net wrote:
> I have a string variable $pointer1->{'shipping'} that evaluates to
>
> "UPS Ground - $20.62" (minus the quotation marks)
>
[snip]
>
> How can I pick the number 20.62 out of this string variable?
This:
#!/usr/bin/perl
my $str = 'UPS - Ground $20.62 ';
if ($str =~ /\$([\d.]+)/ ) {
my $amount = $1;
print "Amount = $amount";
}
seems to work fine...
HTH
Pat.
---
Remove the **NO_SPAM** to reply via email.
------------------------------
Date: Tue, 02 May 2000 00:08:13 GMT
From: kims@tip.net.au (Kim Saunders)
Subject: Re: Problem with $ sign in string
Message-Id: <390e1b90.523343388@news.magna.com.au>
>
>I have a string variable $pointer1->{'shipping'} that evaluates to
>
>"UPS Ground - $20.62" (minus the quotation marks)
>
>and I want to pick the number 20.62 out of it
>
>The $ sign is getting in the way of everything that I try.
>
>If I try:
>
>$shipping_string =~ s/\$//;
That is, substituting $ with nothing...
>and print out the results, then I get
>
>"Shipping String = UPS Ground - .62"
Hmm... you shouldn't, you should get "Shipping String = UPS Ground
20.62"....
>I have tried it with s/\$//o and the same results.
You don't want to substitute!!!
>How can I pick the number 20.62 out of this string variable?
Try this (untested):
$string =~ /([\d\.]+)/;
print $1;
Should give you the first bunch of digits/dots
KimS
------------------------------
Date: Mon, 1 May 2000 17:33:56 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Problem with $ sign in string
Message-Id: <MPG.1377c24b87136ece98a9c9@nntp.hpl.hp.com>
In article <390e17b8.936638725@news.wildapache.net> on Tue, 02 May 2000
00:01:31 GMT, otrcomm@wildapache.net <otrcomm@wildapache.net> says...
> I have a problem that I can not figure out.
Because you are not using the tools that Perl provides to help you
figure things out.
> I have a string variable $pointer1->{'shipping'} that evaluates to
>
> "UPS Ground - $20.62" (minus the quotation marks)
>
> and I want to pick the number 20.62 out of it
>
> The $ sign is getting in the way of everything that I try.
>
> If I try:
>
> $shipping_string =~ s/\$//;
>
> and print out the results, then I get
>
> "Shipping String = UPS Ground - .62"
>
> I have tried it with s/\$//o and the same results.
>
> I have tried quotemeta(), and that does not work.
>
> I realize that this is probably basic stuff, but I am stumped!
>
> How can I pick the number 20.62 out of this string variable?
The number '20.62' was never in your string variable, so how could you
expect to pick it out?
Your persistent use of double-quotes in the post implies that in
testing, you created the test string using:
$shipping_string = "UPS Ground - $20.62"; # (with the quotation marks)
Had you also used the '-w' flag (Oh, God, how I wish that were the
default. Where is 'use newbie;' when we need it?), you would have
discovered that you are interpolating the *undefined* pattern-match
capture string $20. No wonder it disappears when you print the string.
Start *now* to use the '-w' flag (and 'use strict;', which is for
everyone, not just newbies), and many of these problems will vanish.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 01 May 2000 17:10:58 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
To: otrcomm@wildapache.net
Subject: Re: Problem with $ sign in string
Message-Id: <390E1D12.F1AC8692@jpl.nasa.gov>
otrcomm@wildapache.net wrote:
> I have a string variable $pointer1->{'shipping'} that evaluates to
> "UPS Ground - $20.62" (minus the quotation marks)
^ ^
Double quotes have a special meaning in Perl (perlop/'Quote and
Quote-like Operators'). I'd bet $20.62 that your mistake is right
here. Try printing this variable before you manipulate it.
(By the way, double spacing looks weird in posts.)
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: Tue, 2 May 2000 02:14:45 +0200
From: "qwerty" <vioon@hotmil.com>
Subject: resizing an image
Message-Id: <8el6on$96g$1@tesla.a2000.nl>
I am looking for a script, module or subroutine that can resize images.
What i want is something like this :
$newimage= &resize($image,newwith,newheight);
Thanks
------------------------------
Date: Mon, 1 May 2000 15:41:31 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: setting an array in a Struct?
Message-Id: <MPG.1377a7f2f83a92c98a9c5@nntp.hpl.hp.com>
In article <8eksln$271$1@nnrp1.deja.com> on Mon, 01 May 2000 21:24:28
GMT, Crypto-Boy <crypto_boy@my-deja.com> says...
> Two questions:
Boy, your post is certainly Crypto.
> Given the declaration
>
> struct Family => { members => '@' };
What language is that? Not Perl, for sure.
> 1) Why doesn't this work for setting the array:
>
> $Family->members(\@myArray);
That invokes the 'members' method of the object $Family, with the
argument being a reference to the array @myArray.
> 2) This code works, but what the heck does that weird syntax mean?
>
> @{$Family->members} = @myArray;
That assignes the values in the array @myArray to an array referred to
by the value returned by the 'members' method of the object $Family.
What are you really trying to do?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 01 May 2000 16:00:41 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: setting an array in a Struct?
Message-Id: <390E0C99.B5892A02@jpl.nasa.gov>
Larry Rosler wrote:
> In article <8eksln$271$1@nnrp1.deja.com> on Mon, 01 May 2000 21:24:28
> GMT, Crypto-Boy <crypto_boy@my-deja.com> says...
> > Two questions:
>
> Boy, your post is certainly Crypto.
>
> > Given the declaration
> >
> > struct Family => { members => '@' };
>
> What language is that? Not Perl, for sure.
That was my first reaction. My second reaction was to search CPAN for a
'struct' module. What I found was Class::Struct (a part of the perl
distribution since 5.004_05) which is used to 'declare struct-like
datatypes as Perl classes'. The original poster should read the
Class::Struct documentation.
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
Date: Mon, 1 May 2000 17:20:55 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: setting an array in a Struct?
Message-Id: <MPG.1377bf44e9ed866298a9c7@nntp.hpl.hp.com>
In article <390E0C99.B5892A02@jpl.nasa.gov> on Mon, 01 May 2000 16:00:41
-0700, Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov> says...
> Larry Rosler wrote:
> > In article <8eksln$271$1@nnrp1.deja.com> on Mon, 01 May 2000 21:24:28
> > GMT, Crypto-Boy <crypto_boy@my-deja.com> says...
> > > Two questions:
> >
> > Boy, your post is certainly Crypto.
> >
> > > Given the declaration
> > >
> > > struct Family => { members => '@' };
> >
> > What language is that? Not Perl, for sure.
>
> That was my first reaction. My second reaction was to search CPAN for a
> 'struct' module. What I found was Class::Struct (a part of the perl
> distribution since 5.004_05) which is used to 'declare struct-like
> datatypes as Perl classes'. The original poster should read the
> Class::Struct documentation.
I cannot find a statement
use Class::Struct;
in the original post, which would have made the magic manifest. Now
that I have read the documentation, I can see what it is about.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 01 May 2000 15:45:46 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: subroutines in perl4
Message-Id: <390E091A.68DE1B48@My-Deja.com>
> Assistance, including in the form of pointers to the faq, appreciated.
>
http://language.perl.com/all_about/perl425.html
------------------------------
Date: Sat, 29 Apr 2000 14:14:19 +0200
From: "Arash Zeini" <ar.zeini@REMOVEuni-koeln.de>
Subject: Re: Upgrading Perl
Message-Id: <8el0lu$54b$1@news.rrz.Uni-Koeln.DE>
I upgraded Perl on my system and it went well.
Nothing special is needed beside taking care of paths of the vendor supplied
Perl installtion. If you know how and where Perl is installed on your
system, then you can just install it from source accroding to the INSTALL
file regardless if you had an RPM installtion before.
Thanks,
Arash
------------------------------
Date: Mon, 1 May 2000 15:27:08 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: VMS Perl system() truncating lines
Message-Id: <MPG.1377a49ab5b75ce198a9c4@nntp.hpl.hp.com>
In article <8ekqd3$ver$1@nnrp1.deja.com> on Mon, 01 May 2000 20:45:28
GMT, ewilts@my-deja.com <ewilts@my-deja.com> says...
> One of my developers is reporting that the Perl system() call is
> truncating the argument to 256 characters. I'm running Perl 5.005_03.
>
> Is this a known limitation? Can this limit to be expanded to 1K or
> more?
The limitation is not in Perl. It might well be in the command
processor that the system() call is invoking. One way to avoid the
limit would be to supply a list of arguments to system(), instead of a
long string that requires parsing by the command processor.
perldoc -f system
perldoc -f exec
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 1 May 2000 15:01:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: which subs are defined
Message-Id: <MPG.13779e7cb342935d98a9c3@nntp.hpl.hp.com>
In article <8ee431$pqv$1@newsflash.concordia.ca> on 29 Apr 2000 07:47:45
GMT, Neil Kandalgaonkar <nj_kanda@alcor.concordia.ca> says...
...
> my %allowed_func = map { $_ => 1 } qw(display order confirm thanks);
>
> if ( $allowed_func{ $q->param('method') } ) {
> &{$q->param('method')}
> }
>
> Even that uses icky soft references which should give you the
> heebie-jeebies. But this should be secure enough.
With a very small change, that can be written not to use 'icky soft
references'. The soft references seem to be there, in the construction
\&$_ . Nevertheless, the following runs with no complaints:
#!/usr/bin/perl -w
use strict;
my %allowed_func = map { $_ => \&$_ } qw(display order confirm thanks);
sub thanks { print "Thanks\n" }
my $method = 'thanks';
if ( $allowed_func{ $method } ) {
&{$allowed_func{ $method }};
}
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 01 May 2000 17:31:59 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Win98 Pipe problem
Message-Id: <390E21FF.87541DAC@jpl.nasa.gov>
bennyboy00@my-deja.com wrote:
> I changed the test program to try other methods of input such as
> open(Reader, 'route|'). It worked perfectly when I used the open
> command on the route statement. Also it worked on various other
> statements like perl -e... It failed when I tried commands like 'dir'
> that are built into command.com. It worked when it came to commands
> like 'route' that are external programs. So I guess there is something
> with the way that command.com returns it's output on built-in commands
> vs external programs that doesn't work with perl pipes.
>
> So, the question is now, how can I do an equivelant of open(Reader,
> 'dir|') for any command.com built-in command? I have to be able to step
> though the output step by step, as our real-world application prohibits
> us from doing a print <Reader> and skipping the loop.
Another thing you could try is something like 'command /C dir'. Once
again, I can't test it on Win 98 at the moment.
Jon
--
Knowledge is that which remains when what is
learned is forgotten. - Mr. King
------------------------------
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 2918
**************************************