[10666] in Perl-Users-Digest
Perl-Users Digest, Issue: 4258 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 19 18:07:22 1998
Date: Thu, 19 Nov 98 15:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 19 Nov 1998 Volume: 8 Number: 4258
Today's topics:
$ENV{'HTTP_USER_AGENT'} List?? <pingv@molyvos.net>
Re: $ENV{'HTTP_USER_AGENT'} List?? (I R A Aggie)
Re: Calling functions from a hash (Brand Hilton)
cannot exit CGI process after forking <callahan@pmel.noaa.gov>
cannot exit CGI process after forking <callahan@pmel.noaa.gov>
Re: cannot exit CGI process after forking <upsetter@ziplink.net>
Re: cannot exit CGI process after forking (Andrew M. Langmead)
Re: Cutting down refering URL to 30 symbols? (Jonathan Bobin)
Re: Faking flock in MacPerl (Andre L.)
Re: File I/O & text processing (Andrew M. Langmead)
Re: HELP: how to prompt for input from command line? (Jonathan Bobin)
Re: HELP: how to prompt for input from command line? (Brand Hilton)
Re: HELP: how to prompt for input from command line? <uri@fastengines.com>
Re: HELP: how to prompt for input from command line? (Brand Hilton)
Re: HELP: how to prompt for input from command line? (Tad McClellan)
Re: HELP: how to prompt for input from command line? (Brand Hilton)
Re: Lexical var in nested sub <jdporter@min.net>
Re: Lexical var in nested sub (Andrew M. Langmead)
number of elements in an array dennishancy@eaton.com
Re: number of elements in an array <sberg1@tampabay.rr.com>
Re: number of elements in an array <uri@fastengines.com>
Re: number of elements in an array <upsetter@ziplink.net>
Re: number of elements in an array <jdporter@min.net>
pattern matching ha@canes.gsw.peachnet.edu
Re: pattern matching <uri@fastengines.com>
Re: perl documentation date <xah@best.com>
Re: Perl script to automatically find dependencies <uri@fastengines.com>
Re: Perl Usage Survey - interpretations, anyone? <jdporter@min.net>
Re: problem with a sub-routine returning values <jdporter@min.net>
Re: Requesting URLs from a perl script (Jonathan Bobin)
Re: Scope question for Perl <jdporter@min.net>
Re: shopping cart <westmj@esvax.dnet.dupont.com>
Strange Failure ed_c@my-dejanews.com
Re: Strange Failure <merlyn@stonehenge.com>
Re: Strange Failure <sberg1@tampabay.rr.com>
Re: Strange Failure (Brand Hilton)
Re: Strange Failure <uri@fastengines.com>
Re: Strange Failure <uri@fastengines.com>
Re: Strange Failure (Andre L.)
Re: Strange Failure <erik@cthulhu.demon.nl>
Re: Strange Failure (I R A Aggie)
Re: use WIN32::OLE experience with MATLAB ?? (Jan Dubois)
Re: Win32::AdminMisc::UserSetMiscAttributes (Was Re: Wi odinjon@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 19 Nov 1998 23:01:33 +0100
From: "P.Vogel" <pingv@molyvos.net>
Subject: $ENV{'HTTP_USER_AGENT'} List??
Message-Id: <3654953C.70F869A@molyvos.net>
Does anybody know if there is a list with all (or a lot of) possible
$ENV{'HTTP_USER_AGENT'} replies?
Please e-mail me too at: pip@mijnkeldertje.com (I cannot access news
very often.)
TIA
Pip
------------------------------
Date: Thu, 19 Nov 1998 17:26:40 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: $ENV{'HTTP_USER_AGENT'} List??
Message-Id: <fl_aggie-1911981726400001@aggie.coaps.fsu.edu>
In article <3654953C.70F869A@molyvos.net>, "P.Vogel" <pingv@molyvos.net> wrote:
[posted && cc'd]
+ Does anybody know if there is a list with all (or a lot of) possible
+ $ENV{'HTTP_USER_AGENT'} replies?
Kind of pointless:
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("$0/0.3"); # the stuff inside the () gets interpreted as
# HTTP_USER_AGENT, and I can set that to anything
# I want
[etc]
Not to mention the virtual cornucopia of spiders, crawlers and other
beasties that do similar things.
James
------------------------------
Date: 19 Nov 1998 22:09:29 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Calling functions from a hash
Message-Id: <7324up$1c9@mercury.adc.com>
In article <365463D0.B54F556C@saic.com>,
Bruce Mohler <bruce.w.mohler@saic.com> wrote:
> my $Response = &{$Category{$Subcategory}}($Subcategory);
my $Response = &{${$Category}{$Subcategory}}($Subcategory);
But you're kinda scaring me with all those symbolic references.
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: Thu, 19 Nov 1998 12:52:26 -0800
From: Jonathan Callahan <callahan@pmel.noaa.gov>
Subject: cannot exit CGI process after forking
Message-Id: <3654850A.DBE84F7D@pmel.noaa.gov>
We have a perl cgi script which reads some form input, creates an
initialization file and then execs a program which takes a long time.
Unfortunately, our cgi doesn't return, and our browser waits, until the
program is finished. We've tried forking child processes using all the
methods in the camel book:
if ($pid = fork) { #parent
exit 0;
} elsif (defined $pid) { #child
exec 'cd subdirectory; run_long_program';
} else {
die;
}
-or-
fork && exit;
exec 'cd subdirectory; run_long_program';
-or-
unless (fork) { #child
unless (fork) { #grandchild
sleep 1 until getppid == 1;
exec 'cd subdirectory; run_long_program';
exit 0;
}
# first child exits quickly
exit 0;
}
wait; #parent reaps first child quickly;
When we print out the $pid in each test section in the first example it
appears that our CGI is indeed forking. And we are running the long
program and getting appropriate output. But none of these examples
allow the cgi process to return before run_long_program is finished
executing.
Does anyone understand why we're having this problem?
Does it have to do with our server?
Is it something anyone has done successfully?
Frustrated,
-- Jonathan Callahan
------------------------------
Date: Thu, 19 Nov 1998 12:52:42 -0800
From: Jonathan Callahan <callahan@pmel.noaa.gov>
Subject: cannot exit CGI process after forking
Message-Id: <3654851A.72224E86@pmel.noaa.gov>
We have a perl cgi script which reads some form input, creates an
initialization file and then execs a program which takes a long time.
Unfortunately, our cgi doesn't return, and our browser waits, until the
program is finished. We've tried forking child processes using all the
methods in the camel book:
if ($pid = fork) { #parent
exit 0;
} elsif (defined $pid) { #child
exec 'cd subdirectory; run_long_program';
} else {
die;
}
-or-
fork && exit;
exec 'cd subdirectory; run_long_program';
-or-
unless (fork) { #child
unless (fork) { #grandchild
sleep 1 until getppid == 1;
exec 'cd subdirectory; run_long_program';
exit 0;
}
# first child exits quickly
exit 0;
}
wait; #parent reaps first child quickly;
When we print out the $pid in each test section in the first example it
appears that our CGI is indeed forking. And we are running the long
program and getting appropriate output. But none of these examples
allow the cgi process to return before run_long_program is finished
executing.
Does anyone understand why we're having this problem?
Does it have to do with our server?
Is it something anyone has done successfully?
Frustrated,
-- Jonathan Callahan
------------------------------
Date: Thu, 19 Nov 1998 21:16:28 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: cannot exit CGI process after forking
Message-Id: <MU%42.101$SD1.18496@news.shore.net>
Jonathan Callahan <callahan@pmel.noaa.gov> wrote:
: <HTML>
: We have a perl cgi script which reads some form input, creates an initialization
: file and then execs a program which takes a long time. Unfortunately,
: our cgi doesn't return, and our browser waits, until the program is finished.
: We've tried forking child processes using all the methods in the camel
: book:
: <P>i<TT>f ($pid = fork) { #parent</TT>
: <BR><TT> exit 0;</TT>
It's nigh-on impossible to debug your code with all this HTML in it (maybe
that's why it's not working?? :) but one thing to check is that you close
STDOUT in the parent process.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 19 Nov 1998 22:46:31 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: cannot exit CGI process after forking
Message-Id: <F2oxxK.JxJ@world.std.com>
Jonathan Callahan <callahan@pmel.noaa.gov> writes:
><HTML>
(In the future, you might want to set your newsreader to avoid doing
that. Usenet articles are supposed to be plain text, and the HTML
formatting makes your article hard to read.)
>We have a perl cgi script which reads some form input, creates an initialization
>file and then execs a program which takes a long time. Unfortunately,
>our cgi doesn't return, and our browser waits, until the program is finished.
Many HTTP servers use the fact that the standard output stream (STDOUT
in Perl) is closed as a signal that the CGI script is done. When your
fork, you create another copy of STDOUT, and even though the parent
script is done and closes STDOUT, your child is holding its copy open.
Calling close() on STDOUT in the child process might fix things.
Another item to point out is that this behavior is dependent on the
HTTP server, not the perl language. Any CGI script written in any
language will exhibit the same behavior. (Usually when I answer
offtopic language neutral questions I say that a CGI script written in
Fortran, awk, BASIC, or Lisp will do the same thing, but I don't think
you can fork in any of those languages.)
You might be better off asking this question in a newsgroup that deals
with the server that you are using. If you decide to take my advice on
this, you would probably be helped best if you specify which server
and which software version you are using. (Just as if you have a Perl
question for this newsgroup, you would be best off saying which
version of perl you are using.)
--
Andrew Langmead
------------------------------
Date: 19 Nov 1998 21:48:39 GMT
From: jonathan@core.dumped.org (Jonathan Bobin)
Subject: Re: Cutting down refering URL to 30 symbols?
Message-Id: <slrn75954g.dt.jonathan@core.dumped.org>
In article <36530103.0@news.takas.lt>, VYTiS wrote:
>Hello!
>
>I have a problem when using $ENV{'HTTP_REFERER'}:
>Sometimes this URL is longer than 50 or even more symbols.
>And it messes up the page, so I'd like to ask if anyone would
>tell me how to notice when it's over 30 symbols and if it is,
>print only these first 30 symbols and "..."?
>
>Like I have:
>http://www.yahoo.com/cgi-bin/search?perl+example+or+just+anything&20
>And I need:
>http://www.yahoo.com/cgi-bin/s...
>
Try something like (for example purposes only):
my $long_string = $ENV{HTTP_REFERER};
my $desired_length = 30;
my $short_string = substr($long_string, 0, $desired_length);
print $short_string;
--
Jonathan Bobin Dumped Communications
jonathan@xnet.org http://moocat.home.ml.org
I like your SNOOPY POSTER!!
------------------------------
Date: Thu, 19 Nov 1998 17:51:18 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Faking flock in MacPerl
Message-Id: <alecler-1911981751180001@dialup-635.hip.cam.org>
In article <365447FA.6A5D@erols.com>, dejahvu@erols.com wrote:
> The Macintosh doesn't support explicit file locking so Mac Perl doesn't
> either. But the unix web server that i use at my web host *does.* What
>
> The problem stems from my inherent laziness (a virtue!). I don't want to
> have to comment out the calls to flock every time I want to check syntax
> or run the script on my mac.
This is what I do:
$osisMac = $^O =~ /MacOs/i;
....
flock ... unless $osisMac;
HTH,
Andre
------------------------------
Date: Thu, 19 Nov 1998 22:32:49 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: File I/O & text processing
Message-Id: <F2oxAp.3KE@world.std.com>
A Chung <amyun@ricochet.net> writes:
>I would like to open a file and add text or replace text in the same
>file.
In many cases, the best thing to do is to write to a new file, and
then replace the first one with it. See the FAQ entry "How do I change
one line in a file" <URL:http://www.perl.com/CPAN/doc/manual/html/pod/
perlfaq5.html#How_do_I_change_one_line_in_a_fi> for details.
>So far I have figured out that IN and OUT seem to be key words for the
>open command for reading/writing. I would have thought that the
>filehandle parameter would have a key word like this. Then again I am
>new to this.
You seem to be mistaken. Neither "IN", nor "OUT" are keywords. At most
they are common names for filehandles. Take a look at entry for open()
in the perlfunc man page <URL:http://www.perl.com/CPAN/doc/manual/html
/pod/perlfunc/open.html>. A filehandle is opened for input or output
(or append or some combination of the three) by prepending some
special characters to the filename in the second parameter. Filenames
with a "<" or with nothing are opened for reading. Filenames prepended
with a single ">" are opened for writing.
--
Andrew Langmead
------------------------------
Date: 19 Nov 1998 21:51:53 GMT
From: jonathan@core.dumped.org (Jonathan Bobin)
Subject: Re: HELP: how to prompt for input from command line?
Message-Id: <slrn7595al.dt.jonathan@core.dumped.org>
In article <3654589D.8DEA2FA2@ncsa.uiuc.edu>, Marty Blase wrote:
>The subject says it all, really. I need to step through an existing data
>file and prompt the user to enter a new value in the row of data, based on
>the data already there. In other words, for each line of data it needs to
>display the data to the command line and prompt the user for new data to
>append.
>
>I've never had to do this in Perl before. What's the most straightforward
>way?
If you want just one line of data:
print "Enter something: ";
chop($what_they_entered = <STDIN>);
print "You entered: $what_they_entered !\n";
If you want them to enter lots of information and stop asking
when the user types a control+d:
while (<STDIN>)
{
print "Enter something: ";
chop;
push (@entered, <STDIN>);
}
for (@entered)
{
print "One of your lines entered was: $_\n";
}
--
Jonathan Bobin Dumped Communications
jonathan@xnet.org http://moocat.home.ml.org
I could dance till the cows come home. On second thought, I'd rather
dance with the cows till you come home.
-- Groucho Marx
------------------------------
Date: 19 Nov 1998 21:43:00 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: HELP: how to prompt for input from command line?
Message-Id: <7323d4$o125@mercury.adc.com>
In article <3654589D.8DEA2FA2@ncsa.uiuc.edu>,
Marty Blase <mblase@yahoo.com> wrote:
>The subject says it all, really. I need to step through an existing data
>file and prompt the user to enter a new value in the row of data, based on
>the data already there. In other words, for each line of data it needs to
>display the data to the command line and prompt the user for new data to
>append.
>
>I've never had to do this in Perl before. What's the most straightforward
>way?
>
>Thanks for any suggestions --
>
>
>- Marty Blase
> mblase@ncsa.uiuc.edu
print "Enter something -> ";
$something = <>;
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: 19 Nov 1998 17:20:41 -0500
From: Uri Guttman <uri@fastengines.com>
To: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: HELP: how to prompt for input from command line?
Message-Id: <sarhfvvb9za.fsf@camel.fastserv.com>
>>>>> "BH" == Brand Hilton <bhilton@tsg.adc.com> writes:
BH> In article <3654589D.8DEA2FA2@ncsa.uiuc.edu>,
BH> Marty Blase <mblase@yahoo.com> wrote:
>> the data already there. In other words, for each line of data it needs to
>> display the data to the command line and prompt the user for new data to
BH> print "Enter something -> ";
BH> $something = <>;
sorry brand, but you won't see that prompt. you have to turn on $| to
make autoflushing on STDOUT work. by default it only flushes with print
when there is a newline (line buffered).
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: 19 Nov 1998 22:30:13 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: HELP: how to prompt for input from command line?
Message-Id: <73265l$je21@mercury.adc.com>
It's nice that you want to help, but you really should try these
things out before you post them.
In article <slrn7595al.dt.jonathan@core.dumped.org>,
Jonathan Bobin <jonathan@core.dumped.org> wrote:
>
>If you want just one line of data:
>
>print "Enter something: ";
>chop($what_they_entered = <STDIN>);
>print "You entered: $what_they_entered !\n";
This is correct.
>If you want them to enter lots of information and stop asking
>when the user types a control+d:
This is far from correct.
>while (<STDIN>)
So the user enters the first line with no prompt, but then that line
is thrown away.
>{
> print "Enter something: ";
Now, finally, a prompt.
> chop;
You chopped what was entered in the while, but then you don't use it.
> push (@entered, <STDIN>);
This line keeps going until the user hits Ctrl-D, at which point, at
least on my Sun, you go back up to the while. You have to hit two
Ctrl-Ds in a row to get out of the loop.
>}
>
>for (@entered)
>{
> print "One of your lines entered was: $_\n";
>}
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: Thu, 19 Nov 1998 16:22:27 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: HELP: how to prompt for input from command line?
Message-Id: <3n5237.2n2.ln@flash.net>
Marty Blase (mblase@ncsa.uiuc.edu) wrote:
: The subject says it all, really. I need to step through an existing data
: file and prompt the user to enter a new value in the row of data, based on
: the data already there. In other words, for each line of data it needs to
: display the data to the command line and prompt the user for new data to
: append.
: I've never had to do this in Perl before. What's the most straightforward
: way?
while (<>) {
print; # display the data to the command line
print "what do you want to append to the above line?\n";
$answer = <STDIN>; # get the answer from the keyboard
chomp; # take newline off end of original line
$_ .= $answer; # append the new stuff
# now do something with the modified line.
# you neglected to tell us what that might be...
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Nov 1998 22:43:23 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: HELP: how to prompt for input from command line?
Message-Id: <7326ub$1c10@mercury.adc.com>
In article <sarhfvvb9za.fsf@camel.fastserv.com>,
Uri Guttman <uri@fastengines.com> wrote:
>>>>>> "BH" == Brand Hilton <bhilton@tsg.adc.com> writes:
>
> BH> In article <3654589D.8DEA2FA2@ncsa.uiuc.edu>,
> BH> Marty Blase <mblase@yahoo.com> wrote:
> >> the data already there. In other words, for each line of data it needs to
> >> display the data to the command line and prompt the user for new data to
>
> BH> print "Enter something -> ";
> BH> $something = <>;
>
>sorry brand, but you won't see that prompt. you have to turn on $| to
>make autoflushing on STDOUT work. by default it only flushes with print
>when there is a newline (line buffered).
Or when you read from STDIN ;-)
Works on my Solaris, Linux, WinNT, FreeBSD, and HPUX boxes. Woulda
tried more, but I'm lazy and those are the only ones within arm's
reach.
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: Thu, 19 Nov 1998 17:25:50 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Lexical var in nested sub
Message-Id: <36549AEE.8A21DC00@min.net>
Bret Madhvani wrote:
>
> I'm trying to understand the scope of a lexical variable in a nested
> sub.
Don't do this. Nested subs are broken.
Given your decription, I think you don't need them anyway.
If you really do, check out closures instead.
John Porter
------------------------------
Date: Thu, 19 Nov 1998 22:23:08 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Lexical var in nested sub
Message-Id: <F2owuK.D06@world.std.com>
Bret Madhvani <see.address@signature.line> writes:
>My (obviously naive) assumption was that $c would retain its value in
>my_sub_2, just as $b retains its value in my_sub_1. I'm hoping that
>someone can educate me as to why it doesn't. Or, tell me another way to
>do this (that is, make variables retain their values inside nested
>subs).
Be careful of examples using $a and $b as variables. They have special
meanings to perl, and because of that are exempt from the "strict"
pragma. If your variables were named anything else, perl would have
choked on the unqualified global "$a".
(also, I wouldn't call my_sub_2 nested, but more on that later.)
A lexically scoped variable remains visible inside its scope and all
inner scopes. Inside of a block, a variable is visible from its
declaration via my() until the end of the block. Variables outside of
any block have a scope of the entire file.
Since my_sub_2 is declared outside of my_sub_1, my_sub_1's lexically
local variables are not visible. Since b.pl is a different file,
a.pl's lexically scoped variables are not visible. (but since b.pl
doesn't change its default package, variables global to a.pl's package
are visible to b.pl)
You can achieve what you want with dynamically scoped variables. (the
local() operator.) but you should probably rethink your design. You're
essentially treating the variables as globals, and will incure all of
the associated maintanance problems. Pass arguments to the functions
that need them.
a.pl
----------------------------
#!/usr/bin/perl -w
use strict;
require 'b.pl';
use vars qw($a);
$a = 'A (global)';
my $b = 'B (lexical scoped to a.pl)';
my_sub_1($a,$b);
sub my_sub_1 {
my ($a,$b) = @_;
my $c = 'C (lexical scoped to my_sub_1)';
print $a . "\n";
print $b . "\n";
print $c . "\n";
my_sub_2($a,$b,$c);
}
1;
----------------------------
b.pl
----------------------------
sub my_sub_2 {
my ($a,$b,$c) = @_;
print $a . "\n";
print $b . "\n";
print $c . "\n";
}
1;
----------------------------
Now onto the nested subs stuff. (which was why I read it in the first
place. Oh well.)
What most people think of when you say "nested subs" would be similar
to the Pascal language where a procedure or function's (Pascal's terms
for subroutines) is delcared inside of another subroutine's
definition. The reason why some languages use this constuct is that it
documents that my_sub_2 should only be called from my_sub_1. It also
gives access to my_sub_1's variables. (A little like what you were
expecting, but calling "require" inside the subroutine doesn't make
its file lexically scoped within the sub)
If Perl had nested subs, they would look like this.
sub my_sub_1 {
my $c = 'C lexically scoped to my_sub_1';
sub my_sub_2 {
print map { "$_\n" } $a,$b,$c;
}
print map { "$_\n" } $a, $b, $c;
my_sub_2($a,$b,$c);
}
but perl doesn't really like that. It does allow, nearly the same
effect with a codereference assigned to a typeglob.
#!/usr/bin/perl -w
use strict;
$a = 'A global';
my $b = 'B lexically scoped to the file.';
my_sub_1();
sub my_sub_1 {
my $c = 'C lexically scoped to my_sub_1';
local(*my_sub_2) = sub {
print map { "$_\n" } $a,$b,$c;
};
print map { "$_\n" } $a, $b, $c;
my_sub_2($a,$b,$c);
}
--
Andrew Langmead
------------------------------
Date: Thu, 19 Nov 1998 21:12:28 GMT
From: dennishancy@eaton.com
Subject: number of elements in an array
Message-Id: <7321jc$1sa$1@nnrp1.dejanews.com>
Is there a Perl function that will return the number of elements in an array?
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 19 Nov 1998 16:30:21 -0500
From: "Shawn Berg" <sberg1@tampabay.rr.com>
Subject: Re: number of elements in an array
Message-Id: <H8052.3021$QO1.6322599@newse2.tampabay.rr.com>
>Is there a Perl function that will return the number of elements in an
array?
>
$count = scalar(@list);
------------------------------
Date: 19 Nov 1998 16:47:58 -0500
From: Uri Guttman <uri@fastengines.com>
To: dennishancy@eaton.com
Subject: Re: number of elements in an array
Message-Id: <sarogq3bbht.fsf@camel.fastserv.com>
>>>>> "d" == dennishancy <dennishancy@eaton.com> writes:
d> Is there a Perl function that will return the number of elements in
d> an array?
read perldata. it is in there in on page 4 or so.
hth,
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Thu, 19 Nov 1998 22:22:27 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: number of elements in an array
Message-Id: <DS052.107$SD1.17458@news.shore.net>
Shawn Berg <sberg1@tampabay.rr.com> wrote:
:>Is there a Perl function that will return the number of elements in an
: array?
:>
: $count = scalar(@list);
or
$count = @list;
or
$count = $#list + 1
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 19 Nov 1998 17:37:49 -0500
From: John Porter <jdporter@min.net>
Subject: Re: number of elements in an array
Message-Id: <36549DBD.13B49079@min.net>
dennishancy@eaton.com wrote:
>
> Is there a Perl function that will return the number of elements in an array?
This seems like an extremely basic question, doesn't it?
And so one would think that the answer to it should be found somewhere
in the copious documentation that comes with each installation of Perl,
right?
In fact, it's on page 5 of the perldata document, which you can read by
typing
perldoc perldata
at your command prompt. (Hit spacebar to page down through the document.)
John Porter
------------------------------
Date: Thu, 19 Nov 1998 21:46:26 GMT
From: ha@canes.gsw.peachnet.edu
Subject: pattern matching
Message-Id: <7323jc$3sc$1@nnrp1.dejanews.com>
Hi, New to the site but not a novice.
the following statement
if ($file[$counter] =~ /$var/)
produces "Use of an Unitialized Value"
Even if i am able to print it out but apparentlly it makes the compiler ungry,
the if statement is inside a while loop , I tought about scoping problem but
not.
any ideas , suggestion
thanks for your help...... ;)
--------------------------
Habib Adnan
Arlington Massachussettts.
ha@canes.gsw.edu
--------------------------
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 19 Nov 1998 17:26:43 -0500
From: Uri Guttman <uri@fastengines.com>
To: ha@canes.gsw.edu
Subject: Re: pattern matching
Message-Id: <sard86jb9p8.fsf@camel.fastserv.com>
>>>>> "h" == ha <ha@canes.gsw.peachnet.edu> writes:
h> Hi, New to the site but not a novice.
i am a long time listener but a first time caller. :-)
h> if ($file[$counter] =~ /$var/)
h> produces "Use of an Unitialized Value"
sounds like you are using -w, good. are you using strict too?
h> Even if i am able to print it out but apparentlly it makes the
h> compiler ungry,
^^^^^
how 'ungry is the compiler? did it eat the rest of your code? :-) and we
don't write in cockney on the net, just proper american english :-)
that was a real question, where is the rest of the relevant code? we
can't figure out what is undefined from that small code fragment. how
did $var, $counter and @file get set? one (or more) of them was not set
to a value, but we can't see where.
hth,
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Thu, 19 Nov 1998 14:33:29 -0800
From: "Xah" <xah@best.com>
Subject: Re: perl documentation date
Message-Id: <36549cbb$0$12768@nntp1.ba.best.com>
Thanks to Greg Ward and Daniel Grisinger
In article <731n00$3i5$2@news0-alterdial.uu.net>, gward@thrak.cnri.reston.va.us (Greg Ward) wrote:
>If you're reading the online docs as man pages, check the bottom of
>every page.
Ah I see. I missed that because I always use perldoc.
I guess the date stamp in man pages are generated according to
file dates of the perldocs when the man pages are created.
perhaps the date should be in perldocs.as file content.
(hope I'm not being too ignorant for the above suggestion)
In article <m367cblboi.fsf@moiraine.dimensional.com>, Daniel Grisinger <dgris@moiraine.dimensional.com> wrote:
>One thing that can't be said is that the perl community is adverse to
>high quality documentation...
In comparison to your standard run-of-the-mill unix docs, perl
docs perhaps stands out. But in an absolute sense, perl docs
needs lots more work!
For instance, in my opinion, the llama and camel and ram book are
better quality but there's no on-line equivalents.
On-line docs (such as Tom's more-than-you-ever-wanted-to-know
or such) are much much lower quality. Good examples of quality on-line docs
are those from GNU.
(I won't be able to contribute here, but
I'll fart out loud anyway)
Also read Richard Stallman's "Free Software and Free Manuals" at
http://www.gnu.org/philosophy/free-doc.html
There ARE a few quality perl books that's mostly or completely on-line free.
e.g.
MacPerl: Power and Ease by Vicki Brown and Chris Nandor
http://www.ptf.com/macperl/ptf_book/
Joseph Hall's Effective Perl,
http://www.effectiveperl.com/toc.html
Thanks to these authors for their contribution.
Daniel Grisinger wrote
>Yup, in fact the original poster got immediately plonked here.
I hardly see posts with inflammatory remarks accompanied by quality
content from unix folks. Good!
Unix weenies, learn a lesson from Danier Grisinger.
<http://nightflight.com/cgi-bin/foldoc.cgi?Unix+weenie>
Xah, xah@best.com
http://www.best.com/~xah/PageTwo_dir/more.html
"unix = the world's most impressive shit pile"
------------------------------
Date: 19 Nov 1998 16:36:08 -0500
From: Uri Guttman <uri@fastengines.com>
Subject: Re: Perl script to automatically find dependencies
Message-Id: <sarvhkbbc1j.fsf@camel.fastserv.com>
>>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
DG> Uri Guttman <uri@fastengines.com> writes:
>> actually there is a bug in the %INC doc as it calls it an array (see
>> below) and not a hash. also it says that 'do' uses %INC which the docs
>> on 'do' say that there is no checking for previously loaded files using
>> do'.
DG> Yup, the docs should call it a hash, not an array. But there isn't an
DG> error concerning the interaction of do with %INC. do doesn't check
DG> %INC to see if a file has already been required, but it does update
DG> %INC with the name of any file it loads so that future requires will
DG> not reload it.
so repeated do's will reload the file? that is my understanding of it. i
didn't know it updated %INC. the docs don't say that or mention %INC
around 'do' at all.
i just checked and do does modify %INC but doesn't check it.
in any case the docs are wrong by omitting that fact.
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Thu, 19 Nov 1998 16:56:22 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <36549406.C5FA1D21@min.net>
Adam Turoff wrote:
>
> http://www.ora.de/german/perl/einperl2/autor.html
"stinking animals"?!!! Where the heck did that come from?
(Turns out it was "skunks".)
John Porter
------------------------------
Date: Thu, 19 Nov 1998 17:20:29 -0500
From: John Porter <jdporter@min.net>
Subject: Re: problem with a sub-routine returning values
Message-Id: <365499AD.35B82E57@min.net>
Jeff Mallinger wrote:
>
> I have created a my_function routine which works just fine, with one
> exception: it calls another
> function from the Date::Manip library - of which also has a return
> statement (of course, not in the
> simple -1/0/or 1 format which sort is requiring).
>
> What is happening is that sort is picking up the Date::Manip return value
> & croaking because it's
> not the -1, 0, or 1 value that it is expecting.
>
> Is there a way I can make the Date::Manip return value transparent to the
> sort function & keep it
> local to my_function() ?
Please post your code (and trim it down to the minimum code that
illustrates your problem).
And keep your message lines to 72 columns or less. Thanks.
John Porter
------------------------------
Date: 19 Nov 1998 21:54:15 GMT
From: jonathan@core.dumped.org (Jonathan Bobin)
Subject: Re: Requesting URLs from a perl script
Message-Id: <slrn7595f4.dt.jonathan@core.dumped.org>
In article <731on0$h0o$1@ubnnews.unisource.ch>, Admin Sunsite wrote:
>Hi
>
>i have a perl script running on a web-server. Depending on user entries i'd
>like to send the User to a specific URL. How do I do that?
>
>Please reaply to webmaster@sunsite.ch
>
>Thanks for your help!
>
I am assuming you have the URL you want to send them to in
the variable $variable:
print "Content-type: text/html\r\n",
"Redirect: $variable\r\n",
"\r\n";
--
Jonathan Bobin Dumped Communications
jonathan@xnet.org http://moocat.home.ml.org
If you pick up a starving dog and make him prosperous, he will not bite
you. This is the principal difference between a dog and a man.
-- Mark Twain
------------------------------
Date: Thu, 19 Nov 1998 17:05:09 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Scope question for Perl
Message-Id: <36549615.8E4131BE@min.net>
Allan M. Due wrote:
>
> John Porter wrote in message <365323FD.EAF97B1E@min.net>...
> >Get used to declaring all your variables with 'my', and you should be
> >happy.
>
> like all fundamental truths, the path to happiness can be summed up in one
> simple word: my.
You're being sarcastic, but it worked for me!
Because when perl's happy, I'm happy!
Everything I do is motivated by a desire to placate and appease perl.
(and is this not, after all, the 'my' decade?)
John Porter
------------------------------
Date: 19 Nov 1998 22:25:50 GMT
From: Mike West <westmj@esvax.dnet.dupont.com>
Subject: Re: shopping cart
Message-Id: <7325te$hlm@topgun.es.dupont.com>
In article <36541CCD.AEF19CB0@catnmoose.com> Marty Landman,
marty@catnmoose.com writes:
>Dustin Puryear <dpuryear@usa.net> wrote:
>
>>I'm looking for a free shopping cart program that is well
>>documented. Any suggestions?
>
>I'm in the same boat and have picked up the (free) distribution of
>Commerce.cgi from http://www.dial411.com/
>Curious to hear the opinion of others
Why reinvent the wheel? Get http://www.minivend.com/ for free.
In perl, with source. And be amazed.
------------------------------
Date: Thu, 19 Nov 1998 20:40:52 GMT
From: ed_c@my-dejanews.com
Subject: Strange Failure
Message-Id: <731vog$6e$1@nnrp1.dejanews.com>
Hello all:
I am relatively new to PERL but so far I love it. I've written a small
guestbook application and am experiencing a strange problem I hope someone can
help me with. When I add to the guestbook, I want to put the newest record at
the front of the file. I try to find the number of records in the file by
writing:
open( FILENAME, "file.txt );
@Records = <FILENAME>;
$Num = @Records;
For some reason, $Num always is 0, no matter how many lines are in the file.
For what it's worth I'm on NT4 using IIS. Does anybody see anything strange
with this?
Any help would be appreciated.
Thanks,
Ed
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 19 Nov 1998 21:12:25 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Strange Failure
Message-Id: <8c4srvcrpv.fsf@gadget.cscaper.com>
>>>>> "ed" == ed c <ed_c@my-dejanews.com> writes:
ed> For what it's worth I'm on NT4 using IIS. Does anybody see
ed> anything strange with this?
I'm not gonna go there. Nope. Can't make me.
:-)
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 19 Nov 1998 16:34:18 -0500
From: "Shawn Berg" <sberg1@tampabay.rr.com>
Subject: Re: Strange Failure
Message-Id: <sc052.3022$QO1.6324681@newse2.tampabay.rr.com>
> I try to find the number of records in the file by writing:
>
>open( FILENAME, "file.txt );
>@Records = <FILENAME>;
>$Num = @Records;
>
Try:
$Num = scalar(@Records);
------------------------------
Date: 19 Nov 1998 21:39:53 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Strange Failure
Message-Id: <73237a$o124@mercury.adc.com>
In article <731vog$6e$1@nnrp1.dejanews.com>, <ed_c@my-dejanews.com> wrote:
>Hello all:
>
>I am relatively new to PERL but so far I love it. I've written a small
>guestbook application and am experiencing a strange problem I hope someone can
>help me with. When I add to the guestbook, I want to put the newest record at
>the front of the file. I try to find the number of records in the file by
>writing:
>
>open( FILENAME, "file.txt );
>@Records = <FILENAME>;
>$Num = @Records;
>
>For some reason, $Num always is 0, no matter how many lines are in the file.
>For what it's worth I'm on NT4 using IIS. Does anybody see anything strange
>with this?
Alwaysalwaysalways check the return code of open. That's almost
certainly what the problem is.
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: 19 Nov 1998 16:44:54 -0500
From: Uri Guttman <uri@fastengines.com>
To: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Strange Failure
Message-Id: <sarsoffbbmx.fsf@camel.fastserv.com>
>>>>> "RS" == Randal Schwartz <merlyn@stonehenge.com> writes:
>>>>> "ed" == ed c <ed_c@my-dejanews.com> writes:
ed> For what it's worth I'm on NT4 using IIS. Does anybody see
ed> anything strange with this?
RS> I'm not gonna go there. Nope. Can't make me.
RS> :-)
down boy! down! quick someone get the harness and let's tie randal down!
hurry, he is about to explode! help!! help!!!!
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: 19 Nov 1998 16:50:33 -0500
From: Uri Guttman <uri@fastengines.com>
Subject: Re: Strange Failure
Message-Id: <sark90rbbdi.fsf@camel.fastserv.com>
>>>>> "SB" == Shawn Berg <sberg1@tampabay.rr.com> writes:
>> I try to find the number of records in the file by writing:
>>
>> open( FILENAME, "file.txt );
>> @Records = <FILENAME>;
>> $Num = @Records;
>>
SB> Try:
SB> $Num = scalar(@Records);
that is the exact same as:
$Num = @Records;
which he tried, so it can't be the solution.
probably the old "did you check the results of open?" question will lead
the poster onto the path of perl correctness.
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Thu, 19 Nov 1998 17:59:47 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Strange Failure
Message-Id: <alecler-1911981759470001@dialup-635.hip.cam.org>
In article <sc052.3022$QO1.6324681@newse2.tampabay.rr.com>, "Shawn Berg"
<sberg1@tampabay.rr.com> wrote:
> > I try to find the number of records in the file by writing:
> >
> >open( FILENAME, "file.txt );
> >@Records = <FILENAME>;
> >$Num = @Records;
> >
>
>
> Try:
> $Num = scalar(@Records);
same-o.
But checking the result of open() is likely to help.
Also, there's a missing ".
Andre
------------------------------
Date: Thu, 19 Nov 1998 17:33:48 -0500
From: Erik van Roode <erik@cthulhu.demon.nl>
Subject: Re: Strange Failure
Message-Id: <36549CCC.26E1E10D@cthulhu.demon.nl>
ed_c@my-dejanews.com wrote:
> open( FILENAME, "file.txt );
> @Records = <FILENAME>;
> $Num = @Records;
>
> For some reason, $Num always is 0, no matter how many lines are in the file.
> For what it's worth I'm on NT4 using IIS. Does anybody see anything strange
> with this?
Does the open actually succeed? The way you wrote it it doesn't even run ...
Try something like this:
open( FILENAME, "file.txt" ) || die "Could not open file.txt: $!";
Erik
------------------------------
Date: Thu, 19 Nov 1998 17:28:07 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Strange Failure
Message-Id: <fl_aggie-1911981728070001@aggie.coaps.fsu.edu>
In article <sarsoffbbmx.fsf@camel.fastserv.com>, Uri Guttman
<uri@fastengines.com> wrote:
+ down boy! down! quick someone get the harness and let's tie randal down!
+ hurry, he is about to explode! help!! help!!!!
Let him explode. Sure, it'll be messy, but it'll be entertaining, too.
James
------------------------------
Date: Thu, 19 Nov 1998 23:44:41 +0100
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: use WIN32::OLE experience with MATLAB ??
Message-Id: <36549a39.20354548@news3.ibm.net>
[mailed & posted]
Guido Steiner <str@zhwin.ch> wrote:
>I realy hope, that somebody reads this.
>I try to start the MATLAB command window. Well starting the application
>with
>
>$obj= new Win32::OLE 'Matlab.Application' || die "CreateObject : $!";
>
>works, but the MATLAB window just appears in the taskbar and it is not
>possible to verify for example the following command
>
>$result=$obj->Execute("surf(peaks)")
>
>This script fragments do not provokate any errors, but the launched
>application doesn't stay on top and herewith visible.
>
>Is there anybody who has got experience with the Win32::OLE preferably
>in connection with Matlab ?
>
>Which commands do I have to use, when I want to get a visible command
>window ? In general : is that possible or do I have to apply a differnt
>method ?
Hello Guido!
The problem is that the automation server is terminating when your Perl
program stops. I just tried this:
use strict;
use Win32::OLE;
my $matlab = Win32::OLE->new('Matlab.Application');
$matlab->MaximizeCommandWindow;
$matlab->Execute("surf(peaks)");
$_ = <>;
The "MaximizeCommandWindow" makes the command window visible; otherwise it
would stay "hidden" in the task bar. The final "$_ = <>;" just waits for
me to press enter. It now shows the command and the figure window. I can
also enter Matlab commands interactively. When I press ENTER in the Perl
script, the Matlab windows all vanish because the automation object is
destroyed.
I think it should be possible to keep the Matlab session alive even after
the Perl program terminates, but I cannot see how just now. I did write
some Perl modules as wrappers for the Matlab Engine interfaces some time
ago, and Matlab engines do survive termination of the Perl program. And
the Matlab engine interface uses the ActiveX API to communicate with the
server on Win32 as far as I know. But I hope the information above should
get you going anyways.
-Jan
------------------------------
Date: Thu, 19 Nov 1998 22:06:54 GMT
From: odinjon@my-dejanews.com
To: rothd@roth.net
Subject: Re: Win32::AdminMisc::UserSetMiscAttributes (Was Re: Win32 UserCreate )
Message-Id: <7324pg$516$1@nnrp1.dejanews.com>
I solved the problem.
When using the _Get_ variant and leaveing the server value set to nul, you
will pull the data from some available BDC. But when you use the _Set_
variant, you must specify the PDC since that is the only server you can make
changes to.
Thanks to all!
Odin
In article <72ne4t$s4p$1@nnrp1.dejanews.com>,
Odin.Anderson@TDSTelecom.Com wrote:
> I was just scanning some of the perl module archives, and came accross this
> old post.
>
> I'm also having trouble using the UserSetMiscAttributes function in the
> AdminMisc module. I was unable to find any list of issues that may be related
> to this function.
>
> I can't seem to get the UserSetMiscAttributes function to set certain
> attribute values. Can you please let me know if you've had success or
> problems with this function?
>
> Source:
> use Win32::AdminMisc;
> Win32::AdminMisc::UserSetMiscAttributes('', 'OdinTest789',
> USER_HOME_DIR_DRIVE, "i:",)||print "No Set!!!\n";
> Win32::AdminMisc::UserGetMiscAttributes('', 'OdinTest789', \%hash) || die;
> foreach $i (sort keys(%hash)){
> print "$i = ". $hash{$i} ."\n";
> }
>
... stuff deleted
> Perl Version:
> This is perl, version 5.005_02 built for MSWin32-x86-object
> Binary build 504 provided by ActiveState Tool Corp. http://www.ActiveState.com
> Built 14:58:28 Oct 9 1998
>
> AdminMisc Version:
> ftp://ftp.roth.net/pub/ntperl/adminmisc/980511/bin/
> 75994 Oct 8 15:06 File AdminMisc_Build_5_005.zip
>
> Other Background Stuff:
> NT 4.0 SP4 Workstation
> NT 4.0 SP3 Server
> Single Domain Model
> Script run from a Domain Admin account on an NT Workstation
>
> Any input you can provide is greatly appreciated!!!
>
> Odin
> --
> Odin.Anderson@TDSTelecom.Com
> (608) 664-4627
--
Odin
--
Odin@POBox.Com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4258
**************************************