[11561] in Perl-Users-Digest
Perl-Users Digest, Issue: 5161 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 17 20:07:36 1999
Date: Wed, 17 Mar 99 17:00:17 -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 Wed, 17 Mar 1999 Volume: 8 Number: 5161
Today's topics:
Re: About CGI.pm (Michael Smith)
Algorithm to split words into "encyclopedia labels" <pjl@be-NOSPAM-st.com>
Re: echo pwd (Alastair)
Re: echo pwd <jglascoe@giss.nasa.gov>
Re: flock() on Alpha/VMS <brad@tgsmc.com>
Re: flock() on Alpha/VMS <brad@tgsmc.com>
glob failed <srobert@anv.net>
Re: glob failed (Alastair)
Re: how to run scrip on mac via html (Arved Sandstrom)
Re: Need a one liner... <stampes@xilinx.com>
Re: Net::POP3;login method returns 0 with messages on s <snetvil@email.msn.com>
Re: new on subroutines brandtr@my-dejanews.com
Re: Newbe here again... <andy@andymen.demon.co.uk>
Re: Newbie question about form to mail program buumzer@my-dejanews.com
Re: open port from behind firewall, with no proxy <pboldra@spam_to_hell.dynamite.com.au>
Re: Regular Expression Help <klch@hknet.com>
Re: Regular Expression Help <jglascoe@giss.nasa.gov>
Re: Some Perl questions brandtr@my-dejanews.com
Re: the life of brian(the $dbh variable) (Jon Drukman)
Re: Undefined subroutine error <paul.cameron@sun.com>
Win32 Network problems with ActiveState PERL? <xni11@dial.pipex.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Mar 1999 00:45:43 GMT
From: smith@io.com (Michael Smith)
Subject: Re: About CGI.pm
Message-Id: <slrn7f0j7k.fnj.smith@dillinger.io.com>
On Wed, 17 Mar 1999 13:05:23 -0600, Kent Wang
<kentwang@mailcity.com> wrote:
>Just how efficient is CGI.pm? Are there alternatives? What's up with
>LWP?
Alternative: mod_perl <http://perl.apache.org/>.
LWP is not an alternative to CGI.pm, if that's what you're asking --
it's a complete Web client/browser library.
CGI.pm is a library for creating Web forms and processing
information from them.
<opinion>
It seems to me that any inefficiencies CGI.pm may have might concern
you if you're a system administrator for a high-volume Web server,
but not if you are just running scripts as a user/Web-publisher
through a Web hosting service.
Unless you've actually noticed specific problems or inefficiencies
with CGI.pm, I don't think you need to look any further -- that is,
if you don't have mod_perl already and/or are with a Web hosting
service, but can't convince that hosting service to install it.
</opinion>
--
Michael Smith Austin, Texas
smith@io.com
------------------------------
Date: 17 Mar 1999 16:13:40 -0800
From: "Paul J. Lucas" <pjl@be-NOSPAM-st.com>
Subject: Algorithm to split words into "encyclopedia labels"
Message-Id: <pjl.921715632@shell3.ba.best.com>
Given an array of words, I would like to split them into chunks
of size N similarly to the way encyclopedias are split up, i.e.,
on the sides of a multi-volume encyclopedia, you see labels
like:
A-C D-Fa Fe-I ... W-Z
that is: each volume (chunk) is roughly the same size (N);
where possible, volume boundaries are on individual letters;
however, if there are too many words that start with the same
single letter, then the words are further split according to
their second letter (and so on for the third, fourth, etc, if
necessary).
The solution should be an array where each element contains the
starting index into the array of words for every chunk.
Is there an elegant way to do this without lots of looping and
checking words character by character?
E-mail replies preferred.
- Paul
pjl AT best DOT com
P.S.: No, this is not a homework problem; it's a problem for my
real day job.
------------------------------
Date: Thu, 18 Mar 1999 00:07:19 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: echo pwd
Message-Id: <slrn7f0h1h.5j.alastair@calliope.demon.co.uk>
mr_potato_head@my-dejanews.com <mr_potato_head@my-dejanews.com> wrote:
>$directory = `pwd`;
>print "$directory\n";
>
>But this doesn't work. Any ideas? Thanks in advance...
Works for me. Some more information might help. There's also the Cwd module
(standard I believe) ;
perldoc Cwd
HTH/
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Wed, 17 Mar 1999 19:12:53 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: mr_potato_head@my-dejanews.com
Subject: Re: echo pwd
Message-Id: <36F04505.AB960496@giss.nasa.gov>
[courtesy copy of post sent to cited author]
mr_potato_head@my-dejanews.com wrote:
>
> I need to echo the working directory to the screen and I tried using
>
> $directory = `pwd`;
> print "$directory\n";
use Cwd;
print my $dir = cwd, "\n";
Jay Glascoe
--
ping.
------------------------------
Date: 17 Mar 1999 16:43:24 PST
From: Brad Hughes <brad@tgsmc.com>
To: Techno <techno@umbriel.demon.co.uk>
Subject: Re: flock() on Alpha/VMS
Message-Id: <36F04D04.D5D20D61@tgsmc.com>
Techno wrote:
>
> M.J.T. Guy wrote in message <7coqac$610$1@pegasus.csx.cam.ac.uk>...
> >Dan Sugalski <sugalskd@netserve.ous.edu> wrote:
> >>
> >>The VMS port of perl doesn't support flock or fcntl at the moment.
> >>However... VMS has mandatory file locking--if you open a file for write,
> >>nobody else will be able to. (The open call will throw an error) You'll
> >>need a bit more checking on open to detect a locked file error, but you
> >>can skip flock entirely on VMS.
> >
> >Wouldn't it be politer, and assist portability, if flock() was implemented
> >as a no-op on this platform, since that is what it effectively is with
> >mandatory locking?
> >
> >
> >Mike Guy
>
> Mike,
>
> I couldn't agree more, especially as the error returned by flock() in $! is
> 'no more processes'. This set me and my VMS admin guy off on a red-herring
> hunt as we couldn't see any problems with the way the account was set up !!
Hmmm.
$ perl -e "open F, 'sys$login:login.com'; flock F, 0"
The flock() function is unimplemented at -e line 1.
This is with both 5.004_04 and 5.005_02.
Brad
------------------------------
Date: 17 Mar 1999 16:55:51 PST
From: Brad Hughes <brad@tgsmc.com>
To: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: flock() on Alpha/VMS
Message-Id: <36F04FEF.4CB53BBB@tgsmc.com>
Dan Sugalski wrote:
>
> In comp.lang.perl.misc M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
> : Dan Sugalski <sugalskd@netserve.ous.edu> wrote:
> :>
> :>The VMS port of perl doesn't support flock or fcntl at the moment.
> :>However... VMS has mandatory file locking--if you open a file for write,
> :>nobody else will be able to. (The open call will throw an error) You'll
> :>need a bit more checking on open to detect a locked file error, but you
> :>can skip flock entirely on VMS.
>
> : Wouldn't it be politer, and assist portability, if flock() was implemented
> : as a no-op on this platform, since that is what it effectively is with
> : mandatory locking?
>
> It'd be politer, but it'd also be wrong. If you open a file
> read-regardless (which doesn't place any locks on the file), flock(LOCKEX)
> (or whatever the constant is) would return true even though it failed. And
> flock(UNLOCK) on a file opened for write would return true even though it
> didn't do that. The only really good way to handle it would be to have
> flock check the current open mode and return true or false if it matched
> what's being asked for. (Maybe for 5.006....)
>
Or use C<vmsopen> and specify the right control string. Or use VMS::Lock,
which requires some programming. VMS file access control is pretty robust,
and you shouldn't have to kludge up something to conform to cruder models.
Although I can see an C<flock()> wrapper around $ENQ some time in the future...
------------------------------
Date: Wed, 17 Mar 1999 16:38:47 -0800
From: "Steven R. Robertson" <srobert@anv.net>
Subject: glob failed
Message-Id: <36F04B17.57AC1CF5@anv.net>
I'm a total newbie with perl. But I needed to run an install program
that depends on it. When I try to run it I get error messages:
glob failed at line xxx
I tried compiling a new version of perl 5.005.02 and afterwards tried a
precompiled version of the same. During the compilation when I run "make
test" I get similar glob error messages.
This is on Linux 2.0.36 with glibc-2.0.7 libs.
I even tried recompiling and install glibc and then compiling perl. But
"make test" is still giving me the "glob errors".
What can I do?
------------------------------
Date: Thu, 18 Mar 1999 00:52:32 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: glob failed
Message-Id: <slrn7f0jma.d5.alastair@calliope.demon.co.uk>
Steven R. Robertson <srobert@anv.net> wrote:
>I'm a total newbie with perl. But I needed to run an install program
>that depends on it. When I try to run it I get error messages:
>glob failed at line xxx
That's a strange line number.
Who knows? What program? What's on line 'xxx'?
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Wed, 17 Mar 1999 20:20:39 -0400
From: Arved_37@chebucto.ns.ca (Arved Sandstrom)
Subject: Re: how to run scrip on mac via html
Message-Id: <Arved_37-1703992020390001@dyip-96.chebucto.ns.ca>
In article <36F03D9F.4D64DD56@imago.hr>, Super-User <zax@imago.hr> wrote:
> I am new to perl and this newsgroup, so please be gentle with the
> answers.
>
> Is there something I should put down in the first line of the script
> like a path to perl app, and how to set it.
To maintain standardization across platforms, as much as possible, you
should use the #! line in MacPerl scripts. There is a Preferences setting
to look for it, which you ought to check off. This way you can set Perl
options such as -w in the script.
The actual path that you write in is basically irrelevant; you could put
in /usr/local/bin/perl and that would work, or just 'perl', since there is
no concept of PATH per se.
By "via html" I'm assuming that you're thrashing around with CGI. Be
advised that you should save your otherwise completely normal Perl script
as a CGI Script under the MacPerl Save As, so that Apple Events etc
between the script (MacPerl running the script, really) and the web server
happen properly.
As a MacPerl user, if that you be, consider subscribing to one or more of
the MacPerl mailing lists. I can never remember what the sub procedure is
for any mailing list even though I'm on a bunch of them - sorry. :-)
Hope this helps. Arved
------------------------------
Date: 17 Mar 1999 23:25:43 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Need a one liner...
Message-Id: <7cpdln$7p1@courier.xilinx.com>
benbean@yahoo.com wrote:
: What is that ".." notation in the regular expression? I haven't seen that before
: and I can't find mention of it in the books or man pages other than as used in a
: field separator to denote any two characters.
You missed the perlop manpage apparently:
perldoc perlop
Binary ".." is the range operator, which is really two
different operators depending on the context. In a list
context, it returns an array of values counting (by ones)
from the left value to the right value. This is useful for
writing for (1..10) loops and for doing slice operations on
arrays. Be aware that under the current implementation, a
temporary array is created, so you'll burn a lot of memory
if you write something like this:
for (1 .. 1_000_000) {
# code
}
In a scalar context, ".." returns a boolean value. The
operator is bistable, like a flip-flop, and emulates the
line-range (comma) operator of sed, awk, and various
editors. Each ".." operator maintains its own boolean
state. It is false as long as its left operand is false.
Once the left operand is true, the range operator stays true
until the right operand is true, AFTER which the range
operator becomes false again. (It doesn't become false till
the next time the range operator is evaluated. It can test
the right operand and become false on the same evaluation it
became true (as in awk), but it still returns true once. If
you don't want it to test the right operand till the next
evaluation (as in sed), use three dots ("...") instead of
two.) The right operand is not evaluated while the operator
is in the "false" state, and the left operand is not
evaluated while the operator is in the "true" state. The
precedence is a little lower than || and &&. The value
returned is either the null string for false, or a sequence
number (beginning with 1) for true. The sequence number is
reset for each range encountered. The final sequence number
in a range has the string "E0" appended to it, which doesn't
affect its numeric value, but gives you something to search
for if you want to exclude the endpoint. You can exclude
the beginning point by waiting for the sequence number to be
greater than 1. If either operand of scalar ".." is a
numeric literal, that operand is implicitly compared to the
$. variable, the current line number. Examples:
As a scalar operator:
if (101 .. 200) { print; } # print 2nd hundred lines
next line if (1 .. /^$/); # skip header lines
s/^/> / if (/^$/ .. eof()); # quote body
As a list operator:
for (101 .. 200) { print; } # print $_ 100 times
@foo = @foo[0 .. $#foo]; # an expensive no-op
@foo = @foo[$#foo-4 .. $#foo]; # slice last 5 items
The range operator (in a list context) makes use of the
magical auto-increment algorithm if the operands are
strings. You can say
@alphabet = ('A' .. 'Z');
to get all the letters of the alphabet, or
$hexdigit = (0 .. 9, 'a' .. 'f')[$num & 15];
to get a hexadecimal digit, or
@z2 = ('01' .. '31'); print $z2[$mday];
to get dates with leading zeros. If the final value
specified is not in the sequence that the magical increment
would produce, the sequence goes until the next value would
be longer than the final value specified.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Wed, 17 Mar 1999 18:07:36 -0600
From: "Scott" <snetvil@email.msn.com>
Subject: Re: Net::POP3;login method returns 0 with messages on server
Message-Id: <OlYa2LNc#GA.74@upnetnews02.moswest.msn.net>
Sorry, I typo-d the original post. The actual code is not missing the
bracket at the spot indicated below.
Scott wrote in message ...
>I'm using the Net::POP3 module to check mail successfully but, when I try
to
>check the return value for the login method, I always get a '0'. The
>documentation states that login returns the number of messages on the
>server. As I stated above, I have no problems logging into my pop3 server
>and downloading messages but, I always get a '0' from login. Am I
>misunderstanding something or is my implementation wrong?
>
>Code snippet:
>
>BEGIN{use Net::POP3;
>}
>$pop=Net::POP3->new('pop.someserver.com',timeout=>30);
>if(!defined $pop){ #<< just missed this opening bracket in the first
post not in act. code
>
>
> print "Couldn't establish connection!\n";
> exit(0);
> }
>$l=$pop->login("userid","password");
>print "$l\n"
>
>
>Any help is appreciated. I'm using the ActiveState build 509 of Perl
>5.005_02 on Windows 95. (I haven't checked to see if the same thing occurs
>under Unix).
>
>Thanks,
>Scott
>
>Please email courtesy copy of any replies.
>
>
>
------------------------------
Date: Thu, 18 Mar 1999 00:53:53 GMT
From: brandtr@my-dejanews.com
Subject: Re: new on subroutines
Message-Id: <7cpiqt$fbj$1@nnrp1.dejanews.com>
Try putting the subroutine in with the main part on your script and indicate
the main part with curly braces.
#!/usr/bin/perl
{ #BEGIN MAIN
print "Content-type: text/html\n\n";
print "<HTML>
<HEAD>
<TITLE>Perl meets the World Wide Web</TITLE>
</HEAD>
<BODY>
<H1>Hello, World!</H1>\n";
&HTML_Footer;
} # END MAIN
sub HTML_Footer
{ # BEGIN SUB
print "</BODY>
</HTML>\n";
} #END SUB
In article <36efe47b.0@news.hawaii.rr.com>,
"Steve Bowen" <bowens001nospam@hawaii.rr.com> wrote:
> Well Im trying to learn perl
> and
> am using these modules:
>
> main
>
> #!/usr/bin/perl
> # hellowww.pl
> require "htmlend.pl";
> print "Content-type: text/html", "\n\n";
> print "<HTML>", "\n";
> print "<TITLE>Perl meets the World Wide Web</TITLE>", "\n";
> print "</HEAD>", "\n";
> print "BODY>", "\n";
> print "<H1>Hello, World!</H1>", "\n";
> &HTML_Footer;
> # End hellowww.pl
>
> subroutine
>
> #!/usr/bin/perl
> # htmlend.pl
> sub HTML_Footer
> {
> print "\n", "</BODY>", "\n";
> print "</HTML>", "\n";
> } #End HTML_Footer
>
> but it doesnt work I get 500 errors
> Am i messing up in the main module by specifying the location of the
> subroutine file? I have tried several different things
>
> Also one other question. If I say print COUNT 1;
> does this store the value one in a file called COUNT and if so where is the
> file located?
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 18 Mar 1999 00:23:26 +0000
From: Andy Mendelsohn <andy@andymen.demon.co.uk>
To: "Raymond C. Jender" <rcj@lucent.com>
Subject: Re: Newbe here again...
Message-Id: <36F0477D.FE5E87BE@andymen.demon.co.uk>
Raymond C. Jender wrote:
>
> Ok, so far so good. At least I'm progressing on my
> little Perl project.
>
> I have been checking FAQ and manuals but tell me,
> is it me or are the available Perl docs kind of
> ambiguous? Seems so to me.
>
> Anyway, here's a simple thing that I can't seem to find
> a way to do it.
>
> All I want to do is check a digit string and reject it
> if it contains something other then digits. The digit string
> can be up to 10 digits long. Only 0-9 is allowed in the
> string. Comments?
>
> Thank you.
A straightforward regular expression will help you.
here, I'll write it for you :
next if $string !~ /^\d{1,10}$/ ;
Now go and use the wonderful documentation that came with perl and look
up perlre.
hth
andy Mendelsohn
andy@andymen.demon.co.uk
------------------------------
Date: Wed, 17 Mar 1999 23:57:48 GMT
From: buumzer@my-dejanews.com
Subject: Re: Newbie question about form to mail program
Message-Id: <7cpfhn$cdb$1@nnrp1.dejanews.com>
@ is a special character in (some) perl interpreters. Try a backslash in
front of it.
...Allen
In article <7cidod$qcb@bgtnsc03.worldnet.att.net>,
"David Brotman" <dbrotman@worldnet.att.net> wrote:
> Is the line at the top of the script that reads:
>
> #!/usr/local/bin/perl
>
> supposed to include the # sign or is the # sign a comment line? I am just
> trying to get a form mail cgi to work and it keeps giving me a
> misconfiguration error message after I hit the submit button.
>
> Also is this syntax correct?
>
> %alias = ( 'myemail' => 'dbrotman@hotmail.com');
>
> I would appreciate any help!
>
> David Brotman
> dbrotman@hotmail.com
>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 18 Mar 1999 11:30:58 +1100
From: paulboldra <pboldra@spam_to_hell.dynamite.com.au>
Subject: Re: open port from behind firewall, with no proxy
Message-Id: <36F04942.B296DB07@spam_to_hell.dynamite.com.au>
Thanks for everyone's help with this, I got it working using Jame's
suggestions. You might also be interested in the extra 'port-range'
code I added. If my subroutine insisted on using only one port, I
couldn't run two of them at once, so I had to specify a range.
###########################
sub net_get_page
{
my ($url,$post_content) = @_;
my $tries = 0;
$first_reserved_port = 4000;
$last_reserved_port = 4100;
($remote_host,$remote_port,$uri) = &parse_url($url);
while (!$sock)
{
$local_port =
int(rand($last_local_port-$first_local_port))+$first_local_port;
$sock = IO::Socket::INET->new(PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => "tcp",
Type => SOCK_STREAM,
LocalPort => $local_port);
$tries++;
if ($tries>20) { die("couldn't create socket after 50 tries. Last
error:$!\n\n"); }
}
if ($post_content) #form via post
{
send($sock,"POST $uri HTTP/1.0\n", $MSG_EOR);
send($sock,"User-agent: $agent_string\n", $MSG_EOR);
send($sock,"Content-type: application/x-www-form-urlencoded\n",
$MSG_EOR);
send($sock,"Content-length: ".length($post_content)."\n", $MSG_EOR);
send($sock,"\n", $MSG_EOR);
send($sock,"$post_content\n", $MSG_EOR);
}
else #get URL
{
send($sock,"GET $uri HTTP/1.0\n", $MSG_EOR);
send($sock,"User-agent: $agent_string\n", $MSG_EOR);
}
send($sock,"\n\n", $MSG_EOR);
recv($sock, $incoming, $byte_no_more, $MSG_WAITALL);
close($sock);
@lines = split(/\n/, $incoming);
return @lines;
} # end net_get_page
--
Paulboldra
------------------------------
Date: Thu, 18 Mar 1999 08:11:50 +0800
From: Kenneth Lee <klch@hknet.com>
To: Gala Grant <gala@sonic.net>
Subject: Re: Regular Expression Help
Message-Id: <36F044C6.2A2B4457@hknet.com>
Gala Grant wrote:
>
> I am trying to remove a varying amount of a string from the end of it.
>
> "c:\\web\\content\\tbuedit\\alpha\\tools\\pressroom\\releases\\"
>
> what I need is to be able to remove the end of the string up to the nth set
> of \\. I know I could do this by splitting the string into an array, but
> that seems like an impractical way to do it. I am hoping to figure out how
> to read the string from the end and somehow count the \\ .
> Thanks,
> Gala Grant
try,
sub get_sth_at_end
{
$_[0] =~ s!((?:[^\\]+\\){$_[1]})$!!;
$1;
}
$string = "c:\\web\\content\\tbuedit\\alpha\\tools\\pressroom\\releases\\";
print "$string\n";
$removed = get_sth_at_end( $string, 3 );
print "$string\n";
print "$removed\n";
------------------------------
Date: Wed, 17 Mar 1999 19:56:05 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Gala Grant <gala@sonic.net>
Subject: Re: Regular Expression Help
Message-Id: <36F04F25.D1EE4668@giss.nasa.gov>
[courtesy copy of post sent to cited author]
Gala Grant wrote:
>
> "c:\\web\\content\\tbuedit\\alpha\\tools\\pressroom\\releases\\"
>
> what I need is to be able to remove the end of the string up to the nth set
> of \\. I know I could do this by splitting the string into an array, but
> that seems like an impractical way to do it. I am hoping to figure out how
> to read the string from the end and somehow count the \\ .
sorry, but I think split's the way to go. What
you propose would be more natural in C.
This ignores the last "\\", but I don't think
that's significant anyway:
sub nth_slashes {
my @foo = split m"\\", shift;
join "\\", splice @foo, @foo - shift;
}
Jay Glascoe
--
"Just say 'Narf!'."
--Jay Glascoe
------------------------------
Date: Thu, 18 Mar 1999 00:36:27 GMT
From: brandtr@my-dejanews.com
Subject: Re: Some Perl questions
Message-Id: <7cphqa$efb$1@nnrp1.dejanews.com>
I beleive there is a commercial product called Perl2exe that is available to
convert Perl scripts to executables. Check www.perl.com, they should have the
info you're looking for on that.
To get the standard input prompt I think your script should contain something
like:
print "What is your favorite scripting language? ";
$language = <STDIN>;
if($language eq "Perl")
{
print "Congratulations!\n";
}
else
{
print "You're doing it the hard way!\n";
)
In article <7cn19r$b5m$1@nnrp1.dejanews.com>,
gthia@rocketmail.com wrote:
> Hello!
>
> I would like to know if the following is possible. How do compile perl
> codes so that I can run it as an executable file, instead of having to
> type perl prog.cgi or ./prog.cgi from the shell?
>
> Also, does anybody know why, I need to press return everytime I run
> the perl script from shell, then I could see my first standard input
> prompt?
>
> What did I left out??
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 17 Mar 1999 23:54:23 GMT
From: jsd@hudsucker.gamespot.com (Jon Drukman)
Subject: Re: the life of brian(the $dbh variable)
Message-Id: <slrn7f0gpi.1o5d.jsd@hudsucker.gamespot.com>
In article <7cmldc$fm$1@nnrp1.dejanews.com>, hojo wrote:
>To the list,
> I am really missing something with mod_perl and perl and apache and
>such.
you'll probably have better luck asking on the mod_perl mailing list.
but, anyway...
> How do I make a variable in an Apache::Registry script persistant
> forever?
it's impossible. a variable will only exist for the life of the child
process.
> I try use vars qw($dbh), but the variable is gone after
> the request is done.
probably it isn't, but rather you have switched to another child
process. remember that apache uses a pool of children and if you set
$x in child process #1, it will not be available in child process
#2. (and child process #1 might be killed at any moment.)
> Which brings me to another question, how do
> I monitor these variables from construction to destruction other than
> just knowing the code in the scripts?
lots and lots of warn statements, and another window tailing the error
log...
warn "x is $x in child $$"
if you're just trying to do persistent database connections (which is
what it looks like based on your message), you really should use the
Apache::DBI module. it has excellent documentation, make sure you
read it.
--
Jon Drukman jsd@gamespot.com
-----------------------------------------------------------------------
Fear the government that fears your computer.
------------------------------
Date: Thu, 18 Mar 1999 00:27:02 +0000
From: Paul Cameron <paul.cameron@sun.com>
Subject: Re: Undefined subroutine error
Message-Id: <36F04856.C2DDFA2B@sun.com>
John wrote:
> On Tue, 16 Mar 1999 22:02:59 -0800, Paul Cameron <thrase@slip.net>
> wrote:
>
> >John wrote:
> >
> >> I run a perl script via a cgi with no real problem.
> >>
> >> When i run it from a cronjob i get undefined sub-routine
> >> error.
> >>
> >> Does anyone know why i might be getting this ?
> >
> >My remote debugging skills (operating through the medium of
> >telepathy) are rather weak. You'll have to provide more information.
> >
> >1) Like ... uhh, the error message for starters.
> But your common sense skills have crashed.
>
> The error message has been given (read above).
Your paraphrased description of the error message is not very useful.
Here is something approaching what would be looking for, from perldiag.
Undefined sort subroutine "%s" called
(F) The sort comparison routine specified doesn't seem
to exist. Perhaps it's in a different package? See the
sort entry in the perlfunc manpage.
Undefined subroutine &%s called
(F) The subroutine indicated hasn't been defined, or if
it was, it has since been undefined.
Undefined subroutine called
(F) The anonymous subroutine you're trying to call
hasn't been defined, or if it was, it has since been
undefined.
Undefined subroutine in sort
(F) The sort comparison routine specified is declared
but doesn't seem to have been defined yet.
> I was more interested in the reasons why the server
> side gives an error and the user side does not.
My telepathic debugging link was never that strong ...
> I will assume you have run out of cpu on this.
> Or perhaps you may need more memory.
No, my input was incomplete, so I dumped core all over you.
You're own darn fault for not C<use strict;> and -w I guess.
> John
Paul. :-)
PS. No ... I don't sense there being an error on line 17
------------------------------
Date: Thu, 18 Mar 1999 00:05:14 +0000
From: Peter Connolly <xni11@dial.pipex.com>
Subject: Win32 Network problems with ActiveState PERL?
Message-Id: <36F0433A.B5BC1CDB@dial.pipex.com>
Hi All
I'm trying to write a small program using ActiveState PERL 5.09 plus
some BackWeb extensions (which are all working fine). My problem is
that my PERL script can't look on a mapped drive. The code below works
fine when the drive in question is a local drive. If the drive is
mapped through Windows NT as a share, it can't locate the files and
halts. I can't see why it shouldn't work - I've tried it many times
logged in as administrator all seems well until I try to access the
maped drive, at which point the PERL code starts to look for files,
then halts without an error.
Are there any problems with Activestate PERL and mapped drives? I can't
see any reasons for it going wrong. I've started the NT process as a
proper login account under the user administrator, not system, yet it
still refuses to work. If anyone can make this code work across mapped
drives, I would be most grateful.
Thanks
Peter
Code Begin>>>
> my $Thisline, $Filename, $NumFiles=0, $Date, $Time, @TheFile = (), @DataLines = (), @TotalLine = ();
> my $LastAcd = "", $Acd, $CallsAnswered, $CallsAbandoned, $AvgDelay, $Percent, $Count;
> my $StoryCount, $cnt = 0;
> my @Allfiles = (), $source_dir = 'g:/', @sorted_files = (), @stats_files = ();
>
> #change the value below to anything other than 0 to output debug information.
>
> my $debug = 1;
>
> if ($debug)
> {
> BW_log_and_print("Starting to look for files....");
> }
>
> opendir (DIR, $source_dir) || die "Cannot open $!";
> while($Allfiles[$cnt] = readdir(DIR)) {
> if ($Allfiles[$cnt] ne "." and $Allfiles[$cnt] ne ".."){
> chdir($source_dir);
>
> # This bit may be used in the future for testing timestamps of the files to see if they're recent. For now we're assuming that the files
> # are cleared down each evening.
> #
> # $created = (-C $Allfiles[$cnt]);
> # $modified = (-M $Allfiles[$cnt]);
> # $accessed = (-A $Allfiles[$cnt]);
> # $read = (-r $Allfiles[$cnt]);
> # BW_log_and_print("Filename:$Allfiles[$cnt], Created:$created,
> # Modified:$modified, Accessed:$accessed, Read:$read");
> $cnt++;
> }
> }
> if ($debug)
> {
> BW_log_and_print("Found $cnt files. Sorting...");
> }
>
> @sorted_files = sort @Allfiles;
> @stats_files = grep { /stats.\d{3}/ } @sorted_files; # We're only interested in files named stats.xxx, where xxx is a three digit extension
>
> if ($debug)
> {
> BW_log_and_print("\nOriginal List: @Allfiles\nSorted List: @sorted_files\nJust the stats files: @stats_files\n");
> }
>
> $NumFiles = $#stats_files;
> if ($NumFiles == -1) { BW_die("Couldn't find any files matching stats.xxx - Exiting...\n"); }
>
> if ($debug)
> {
> BW_log_and_print("Last element in list is $NumFiles.");
> }
>
> $Filename = $stats_files[$NumFiles];
>
> if ($debug)
> {
> BW_log_and_print("File $NumFiles is called $Filename.");
> }
>
> open (INFILE , $Filename) or BW_die("I can't open the file $Filename. ");
>
>
This will work on most Win32 systems, but for some reason fails as a
service sub-process under Windows NT. I'm totally lost from here on.
Does anyone have any clues?
Thanks
Peter
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5161
**************************************