[24059] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6256 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 14 14:05:33 2004

Date: Sun, 14 Mar 2004 11:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 14 Mar 2004     Volume: 10 Number: 6256

Today's topics:
        2D array of objects. <mail@annuna.com>
        Curses-1.06 on mac OS X 10.3.2 compilation error <demonNOSPAM@demon.com.mx>
        decoding quoted-printable $_@_.%_
    Re: decoding quoted-printable <jwillmore@remove.adelphia.net>
    Re: decoding quoted-printable $_@_.%_
        env perl or simply perl? <graffitiNOSPAM@NOSPAMyahoo.com>
    Re: env perl or simply perl? <tassilo.parseval@rwth-aachen.de>
    Re: env perl or simply perl? <jwillmore@remove.adelphia.net>
    Re: env perl or simply perl? (Randal L. Schwartz)
    Re: env perl or simply perl? (Peter J. Acklam)
    Re: How to remove lines containing "continuation" opera <sgovindachar@yahoo.com>
    Re: How to remove lines containing "continuation" opera (werlax)
    Re: how to reset a variable <6tc1@qlinkDOTqueensu.ca>
    Re: how to reset a variable <Joe.Smith@inwap.com>
    Re: how to reset a variable <6tc1@qlinkDOTqueensu.ca>
        How to use select to wait for input <jbstick@aol.com>
    Re: open(filehandle... is failing <dave@nowhere.com>
    Re: open(filehandle... is failing <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: oracle socket creation <Juha.Laiho@iki.fi>
    Re: oracle socket creation <vetro@online.no>
    Re: Splitting filenames to extract a string <Joe.Smith@inwap.com>
    Re: Splitting filenames to extract a string <roel-perl@st2x.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 14 Mar 2004 05:25:46 GMT
From: Joe <mail@annuna.com>
Subject: 2D array of objects.
Message-Id: <u1S4c.37311$aT1.26800@newsread1.news.pas.earthlink.net>

I have been playing with C++ for a while but now I am back to perl. 
Mainly because I can figure out TK and I need a good book for a total 
beginner with GUI in C++.

But my question is that I have a program in C++ that looks like this

space maze[30][30];


that would be:
$board[$lp1][$lp2] = Space::make($map1[$lp1][$lp2]);

then I I want to call a finction in the space object, I have
$board[$play->[$tx]][$play->[$ty]]->blocked()

which would be the equivelant to

board[x][y].blocked();

Any suggestions?



------------------------------

Date: Sun, 14 Mar 2004 10:29:23 -0600
From: Adrian de los Santos <demonNOSPAM@demon.com.mx>
Subject: Curses-1.06 on mac OS X 10.3.2 compilation error
Message-Id: <c32193$221c3k$1@ID-86516.news.uni-berlin.de>

Hi guys, i'm trying to compile the curses module for darwin 7.0 (Apple 
OS X 10.3.2, alias panther) but since every attempt i try fails, i come 
here to see if someone can help me.

I have tried with several hint files (darwin, freebsd,openbsd, netbsd, 
next, and even some suggested on usenet), and with all, the compilation 
fails.

Specifically here its the compile error:

---
cc -c   -g -pipe -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp 
-fno-strict-aliasing -I/usr/local/include -Os   -DVERSION=\"1.06\" 
-DXS_VERSION=\"1.06\"  
"-I/System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE"   
Curses.c
cc1: warning: changing search order for system directory "/usr/local/include"
cc1: warning:   as it has already been specified as a non-system directory
Curses.c: In function `c_sv2window':
Curses.c:275: warning: passing arg 1 of `Perl_sv_isa' from incompatible 
pointertype
Curses.c:275: warning: passing arg 2 of `Perl_sv_isa' from incompatible 
pointertype
Curses.c:275: too few arguments to function `Perl_sv_isa'
In file included from Curses.c:344:
CursesFun.c: In function `XS_Curses_newterm':
CursesFun.c:1279: warning: initialization from incompatible pointer type
CursesFun.c:1280: warning: initialization from incompatible pointer type
CursesFun.c: In function `XS_Curses_putwin':
CursesFun.c:3453: warning: initialization from incompatible pointer type
CursesFun.c: In function `XS_Curses_getwin':
CursesFun.c:3472: warning: initialization from incompatible pointer type
make: *** [Curses.o] Error 1

---

And here its my current c-config.h file

---
#include <curses.h>

#ifdef C_PANELSUPPORT
#include <panel.h>
#endif

#ifdef C_MENUSUPPORT
#include <menu.h>
#endif

#ifdef C_FORMSUPPORT
#include "/usr/include/form.h"
#endif

#define C_LONGNAME
#define  C_LONG0ARGS
#undef C_LONG2ARGS

#define C_TOUCHLINE
#define  C_TOUCH3ARGS
#undef C_TOUCH4ARGS


#undef bool
#undef instr
---

My os and gcc details:

--
# uname -a
Darwin hawking.local 7.2.0 Darwin Kernel Version 7.2.0: Thu Dec 11 
16:20:23 PST2003; root:xnu/xnu-517.3.7.obj~1/RELEASE_PPC  Power 
Macintosh powerpc

# gcc --version
gcc (GCC) 3.1 20021003 (prerelease)
--

Can someone please help me ?

Thanks.



------------------------------

Date: Sun, 14 Mar 2004 05:13:55 GMT
From: $_@_.%_
Subject: decoding quoted-printable
Message-Id: <nSR4c.1344$Q2.251@nwrdny03.gnilink.net>


Has anyone here made a newsreader before?
If so, have you dealt with decoding quoted printable messages
which do not have the "Content-Transfer-Encoding: quoted-printable"
in the actual header but in the body of the message?

Here is an example message.

[top of header snipped]
NNTP-Posting-Date: Mon, 8 Mar 2004 18:03:50 +0000 (UTC)
Xref: cyclone1.gnilink.net comp.lang.perl.tk:15026
X-Received-Date: Mon, 08 Mar 2004 13:15:10 EST (nwrdny01.gnilink.net)


--=-=-=
Content-Transfer-Encoding: quoted-printable

[rest of example message snipped]


--
abcd=7D







------------------------------

Date: Sun, 14 Mar 2004 07:52:50 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: decoding quoted-printable
Message-Id: <pan.2004.03.14.12.52.48.232146@remove.adelphia.net>

On Sun, 14 Mar 2004 05:13:55 +0000, $_ wrote:


> Has anyone here made a newsreader?

Yes.  There are rather length threads on 'nntp'.  Use Google to search for
them

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Great minds run in great circles. 




------------------------------

Date: Sun, 14 Mar 2004 17:59:10 GMT
From: $_@_.%_
Subject: Re: decoding quoted-printable
Message-Id: <O315c.3159$Q2.470@nwrdny03.gnilink.net>


James Willmore <jwillmore@remove.adelphia.net> wrote in message-id:
<pan.2004.03.14.12.52.48.232146@remove.adelphia.net>
>
>
>On Sun, 14 Mar 2004 05:13:55 +0000, $_ wrote:
>
>
>> Has anyone here made a newsreader?
>
>Yes.  There are rather length threads on 'nntp'.  Use Google to search for
>them
>
>HTH
>
>--
>Jim
>
>Copyright notice: all code written by the author in this post is
> released under the GPL. http://www.gnu.org/licenses/gpl.txt
>for more information.
>
>a fortune quote ...
>Great minds run in great circles.

Thanks for the tip, I ended up just using a simple RegEx.


--


------------------------------

Date: Sun, 14 Mar 2004 10:40:56 GMT
From: Berk Birand <graffitiNOSPAM@NOSPAMyahoo.com>
Subject: env perl or simply perl?
Message-Id: <31343be655beb9c3500756b44703870b@news.teranews.com>

Hi,

I am just starting out to learn perl. I have begun by reading the
wonderful manual pages that comes with it. There, they define the first
line of the script as:
#!/bin/env perl

I used this construct for a couple days. Then I got the O'Reilly book
Learning Perl. In that one, they simply define it:
#!/usr/bin/perl

This seems a lot more logical. Plus we also have the ability to add the -w
switch. However I am wondering whether the env version is more accurate,
since Learning Perl is designed for absolute beginners.

Which one would you prefer? How do you use the -w switch with the env
version?

Thanks and Best Regards,
BB


------------------------------

Date: 14 Mar 2004 11:00:36 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: env perl or simply perl?
Message-Id: <c31e0k$mod$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Berk Birand:

> I am just starting out to learn perl. I have begun by reading the
> wonderful manual pages that comes with it. There, they define the first
> line of the script as:
> #!/bin/env perl
> 
> I used this construct for a couple days. Then I got the O'Reilly book
> Learning Perl. In that one, they simply define it:
> #!/usr/bin/perl
> 
> This seems a lot more logical. Plus we also have the ability to add the -w
> switch. However I am wondering whether the env version is more accurate,
> since Learning Perl is designed for absolute beginners.
> 
> Which one would you prefer? How do you use the -w switch with the env
> version?

The same way as you'd use it with the plain /usr/bin/perl:

    #!/bin/env perl -w

I suppose that 'env' is used for the sake of portability. However,
'/bin/env' might not be that portable as for me it would have to be
'/usr/bin/env' for some reason.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


------------------------------

Date: Sun, 14 Mar 2004 07:59:58 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: env perl or simply perl?
Message-Id: <pan.2004.03.14.12.59.56.664084@remove.adelphia.net>

On Sun, 14 Mar 2004 10:40:56 +0000, Berk Birand wrote:

> Hi,
> 
> I am just starting out to learn perl. I have begun by reading the
> wonderful manual pages that comes with it. There, they define the first
> line of the script as:
> #!/bin/env perl
> 
> I used this construct for a couple days. Then I got the O'Reilly book
> Learning Perl. In that one, they simply define it:
> #!/usr/bin/perl
> 
> This seems a lot more logical. Plus we also have the ability to add the -w
> switch. However I am wondering whether the env version is more accurate,
> since Learning Perl is designed for absolute beginners.
> 
> Which one would you prefer? How do you use the -w switch with the env
> version?


`perldoc perlrun`

[from the perlrun POD (aka man page)]


       A similar trick involves the env program, if you have it.

           #!/usr/bin/env perl

       The examples above use a relative path to the perl inter­
       preter, getting whatever version is first in the user's
       path.  If you want a specific version of Perl, say,
       perl5.005_57, you should place that directly in the #!
       line's path.

       If the #! line does not contain the word "perl", the pro­
       gram named after the #! is executed instead of the Perl
       interpreter.  This is slightly bizarre, but it helps peo­
       ple on machines that don't do #!, because they can tell a
       program that their SHELL is /usr/bin/perl, and Perl will
       then dispatch the program to the correct interpreter for
       them.

So, the way I read this is ... use the 'env' appraoch if you can't use the
shabang (first line of the script) to execute the perl interpreter or you
have a really weird install of perl (like, it's in /opt/sfw/perl/bin or
something along those lines).

Just my $0.02

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Real Users are afraid they'll break the machine -- but they're never
afraid to break your face. 



------------------------------

Date: 14 Mar 2004 08:25:03 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: env perl or simply perl?
Message-Id: <864qsrxuow.fsf@blue.stonehenge.com>

*** post for FREE via your newsreader at post.newsfeed.com ***

>>>>> "Tassilo" == Tassilo v Parseval <tassilo.parseval@rwth-aachen.de> writes:

Tassilo> The same way as you'd use it with the plain /usr/bin/perl:

Tassilo>     #!/bin/env perl -w

Tassilo> I suppose that 'env' is used for the sake of portability. However,
Tassilo> '/bin/env' might not be that portable as for me it would have to be
Tassilo> '/usr/bin/env' for some reason.

Seconded on the "reduced portability".  The shebang path has to be
accurate.  Throwing "env" into the mix means that env has to exist at
a known location.  Some systems don't have it, some system have it at
/bin/env, and some systems have it at /usr/bin/env... so you're only
portable within a subset of machines.

Also, you're then also doing a double-launch.  First, the kernel
launches env, then env has to wake up and figure out where Perl is,
and then launch that.

And, if that wasn't enough, you risk that your script will be run by a
privately installed Perl when someone else runs it... which might not
have the right version or the right installed modules.  An explicit #!
path never depends on PATH, so that's not an issue.

So, in general, avoid this strategy when you can.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


 -----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
http://www.newsfeed.com - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----
                  


------------------------------

Date: 14 Mar 2004 18:23:36 +0100
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: env perl or simply perl?
Message-Id: <y8q32vhj.fsf@online.no>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote:

> The same way as you'd use it with the plain /usr/bin/perl:
> 
>     #!/bin/env perl -w

How many operating systems allows this?  To my knowledge, Solaris
is the only one.

I use

     #!/usr/bin/env perl
     (...)
     use strict;
     BEGIN { $^W = 1 }

for three reasons

   1) "perl" is installed at different locations, so I can't
      hardcode the path to perl on the #!-line

   2) "#!/usr/bin/env perl -w" only works on Solaris, not Linux
      and other unices (they say that "perl -w" is an unknown
      command), so I prefer enabling warnings in the actual code

   3) "BEGIN { $^W = 1 }" is because some of the systems have
      older perls which don't understand "use warnings;"

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


------------------------------

Date: Sun, 14 Mar 2004 02:46:27 GMT
From: "Suresh Govindachar" <sgovindachar@yahoo.com>
Subject: Re: How to remove lines containing "continuation" operator
Message-Id: <7IP4c.8492$_3.107020@typhoon.sonic.net>

#!/usr/bin/perl
use warnings;
use strict;
#BEGIN {(*STDERR = *STDOUT) || die;}

=head
"werlax"
asked on Saturday, March 13, 2004 4:46 PM

  [for a good way to remove lines in C-code that
   begin with "#pragma" and which may spill over
   to multiple lines via C's line-continutaion
   character "\" (there is no white space after
   the line continuation character).]

Here's a one liner that does the job!
(In case you don't know, <DATA> refers to the
stuff that follows __DATA__.)

--Suresh

=cut

my $onelinertemplate = '^\s*#pragma.*[^\\\\\\r\\n]+$';
my $starttemplate    = '^\s*#pragma.*\\\\$';
my $endtemplate      = '[\\\\]$';

my @non_pragma_c;

push @non_pragma_c,
     grep !(/$starttemplate/ .. !/$endtemplate/),
     grep !/$onelinertemplate/, (<DATA>);

print @non_pragma_c;

__DATA__
This constitues a file for testing the preceding code.
The OP was hoping to come up with a simple -i -e method.
Is this possible?

#pragma  which is all done on one line only

#pragma has white space after line continuation  \
and so this line should appear

An example line.  All lines to be removed begin with
the "#pragma" statement.

#pragma export(ConfigurationRepository::write\
   (char** ppsBuffer,const string& strTSTAMP_TRANS,\
   const short iUNIQUENESS_KEY))

I hope I provided enough information.
Thanks for any help!

__END__





------------------------------

Date: 14 Mar 2004 06:53:24 -0800
From: werlax@hotmail.com (werlax)
Subject: Re: How to remove lines containing "continuation" operator
Message-Id: <744cd116.0403140653.7de0bae9@posting.google.com>

"Suresh Govindachar" <sgovindachar@yahoo.com> wrote in message news:<7IP4c.8492$_3.107020@typhoon.sonic.net>...
> my $onelinertemplate = '^\s*#pragma.*[^\\\\\\r\\n]+$';
> my $starttemplate    = '^\s*#pragma.*\\\\$';
> my $endtemplate      = '[\\\\]$';
>
Can you explain why you have all the \ characters?  I understand that
you're escaping the literals and metacharacters.  It appears to me
that you've got 2 \'s in there.  What's the thought process behind
that?
Thanks for the response!
Mark


------------------------------

Date: Sat, 13 Mar 2004 20:55:28 -0500
From: "Novice" <6tc1@qlinkDOTqueensu.ca>
Subject: Re: how to reset a variable
Message-Id: <c30e2f$t1f$1@knot.queensu.ca>


"Tore Aursand" <tore@aursand.no> wrote in message
news:pan.2004.03.14.00.02.58.913219@aursand.no...
> On Sun, 14 Mar 2004 00:07:46 +0100, Gunnar Hjalmarsson wrote:
> >> What is actually the _point_ of posting "false" code if you want help?
>
> > Actually, in the Posting Guidelines posters are advised to post "false"
> > code:
> > [...]
>
> Fair enough, but I was referring to the following statement:
>
>   "This code does not exist in any program of mine.  This code is an
>    example of a small subset of the logic that exists in my code."
>
> Do I misunderstand something here?  I understand very well that one
> shouldn't post thousands of lines of code, but instead try to post what's
> relevant, but the "small subset of the logic" confused me.

The logic contained in the program is how the program works - i.e. the
conditionals, loop structures, etc.  The subset of the total logic in a
program is a portion of the above logic.  I removed the logic (that wasn't
relevant to my problem), but the variable names are different and  most of
the sub steps involved with the variables in the original program were
removed.

I believed that if I had left the variable names the same and including much
of the intermediate "logic" (code) then the code would have been too long to
understand.

I hope that clarifies my original motivation for posting a "subset of the
logic" contained in my actual program.

Thanks,
Novice

[snip]




------------------------------

Date: Sun, 14 Mar 2004 07:22:19 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: how to reset a variable
Message-Id: <KKT4c.10122$_w.276848@attbi_s53>

Novice wrote:

> I believed that if I had left the variable names the same and including much
> of the intermediate "logic" (code) then the code would have been too long to
> understand.
> 
> I hope that clarifies my original motivation for posting a "subset of the
> logic" contained in my actual program.

Sounds like you posted some altered lines of your big program, instead
of posting all the lines of a little program.

The best way to get help is to post the complete contents of a small
test program that reproduces the symptoms.  Better yet if it compiles
cleanly with "use strict; use warnings;".

I interpreted your request for something like this:

our $debug = 1;
my @lines = <>;		# Or whatever you used to set up the array
chomp @lines;
{			# Start a new block to limit scope of 'my' vars
   my $firstmatch;
   my $lastmatch;
   foreach (@lines) {
     if (/^someTextImParsingOnANewLine/) {
       print "Match found: $_\n" if $debug;
       $firstmatch = $_ unless defined $firstmatch;
       $lastmatch = $_;
       do_some_processing($lastmatch);
     }
     # Additional tests on $_ go here
   }
   if (defined $firstmatch) {
     print "First match: $firstmatch\n";
     print "Last match:  $lastmatch\n";
   } else {
     print "No matches were found in this loop\n";
   }
}


------------------------------

Date: Sun, 14 Mar 2004 11:14:29 -0500
From: "Novice" <6tc1@qlinkDOTqueensu.ca>
Subject: Re: how to reset a variable
Message-Id: <c320d4$828$1@knot.queensu.ca>


"Joe Smith" <Joe.Smith@inwap.com> wrote in message
news:KKT4c.10122$_w.276848@attbi_s53...
> Novice wrote:
>
> > I believed that if I had left the variable names the same and including
much
> > of the intermediate "logic" (code) then the code would have been too
long to
> > understand.
> >
> > I hope that clarifies my original motivation for posting a "subset of
the
> > logic" contained in my actual program.
>
> Sounds like you posted some altered lines of your big program, instead
> of posting all the lines of a little program.

First I want to say thank you to all of the posters who originally answered
my question.  But secondly, I actually did post MOST of the lines of a
little program (that I had created after I encountered the problem in my big
program) and not just the altered lines of my big program.  The problem is
that when I did this (and I believe they would have done the same if I had
posted ALL of the lines of my little program), most of the Perl people
started looking at ways of writing the code better - more optimized - which
doesn't answer my original question of how to reset the values in a variable
on each iteration of a loop.


[snipped because my newsserver doesn't let me post unless I post more than
the original contents of the message]

Sorry I snipped your answer - my newsserver won't let me post unless I post
more than what was contained in the original message.

Thank you for your solution - I actually can't use the "for each" construct
because I need to do some iterations within the outer looping structure -
therefore I need access to the index/counter for the lines.

Also, I've never seen this syntax before:

our $debug = 1;
or
$firstmatch = $_ unless defined $firstmatch;

I'll have to read up on that.

Thanks again,
Novice




------------------------------

Date: Sun, 14 Mar 2004 18:38:07 GMT
From: "Joe" <jbstick@aol.com>
Subject: How to use select to wait for input
Message-Id: <jE15c.10048$lD6.6000@newssvr27.news.prodigy.com>

I am trying to wait until some commands are appended to a text file.
I tried using select as in the script below, but find that select always
returns immediately, even if the file is empty or at end of file.
What am I missing??

sysopen(CMND,$command_file,O_RDONLY);
$rin = '';
vec($rin,fileno(CMND),1) = 1;

# while (1) {
for ($i = 0; $i < 3; $i++) {
  $cmnds = '';
  $nfound = select($rout=$rin, undef, $eout=$rin, 10);
  if ($nfound) {
    $count = sysread CMND,$cmnds,2048;
    if ($count) {
      MsgLog("select returns: $nfound, sysread returns: $count,
Received:$cmnds");
    }
   else { MsgLog("select returned, but no input"); }
  }
  else { MsgLog('no commands'); }
}





------------------------------

Date: Sat, 13 Mar 2004 21:04:05 -0800
From: Dave Smith <dave@nowhere.com>
Subject: Re: open(filehandle... is failing
Message-Id: <dave-A9E5EB.21040513032004@corp.supernews.com>

Thanks for the post Keith. Do I simply place the unix command inside the 
parenths? I'm not familiar with this command (uh oh, just demonstrated 
I'm a newbie). Thanks again,

Dave

>With system() you can read the return
> value of qmail-inject, which may help figure out what's going wrong.
> Your qmail logs may be helpful, as well (help for qmail you should
> probably find elsewhere).
> 
> - --keith
>


------------------------------

Date: Sat, 13 Mar 2004 21:51:30 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: open(filehandle... is failing
Message-Id: <2tr03c.jlf.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On 2004-03-14, Dave Smith <dave@nowhere.com> wrote:
> Thanks for the post Keith. Do I simply place the unix command inside the 
> parenths? I'm not familiar with this command (uh oh, just demonstrated 
> I'm a newbie). Thanks again,

perldoc -f system

- --keith

- -- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAU/LihVcNCxZ5ID8RAp64AJ99NVLfC3aK+3VgUs7eFvLqPwnpQACeKTrp
wwFyn2oJljDiaSMOXiKdpMk=
=DUIw
-----END PGP SIGNATURE-----


------------------------------

Date: Sun, 14 Mar 2004 12:22:00 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: oracle socket creation
Message-Id: <c31igq$4e9$2@ichaos.ichaos-int>

Vetle Roeim <vetro@online.no> said:
>* Kevin Michael Vail
>> And DBI has a "ping" method to tell if the database is alive, but I 
>> don't know if this is implemented in the Oracle driver.
>
>  From the original posting:
>
>    >> > Goal:
>    >> > send select statement to oracle DB every 5 minutes or so to
>    >> > verify that it is up and running.  Capture output and
>    >> > translate to pass/fail on web page
>
>  That's how he want's to monitor it. There's no need for some sort of
>  "ping" functionality.

The OP would be the best to comment on this, but I'd expect that in
reality his goal is by whatever means verify whether the DB is
serving requests or not. If ESP was seen as a good and economic
alternative for this, then it'd be as good tool as anything else.

Looking at the code of DBD::Oracle tells very fast, though, that what
the ping() method does is "select SYSDATE from DUAL", so this matches
exactly what the OP was looking for. Of course, this is just the current
implementation, and future implementations may change, as long as the
outside functionality (reliably telling whether or not the database is
serving requests) remains.

As for using an arbitary query for finding out the database status, I
have a slight horror story. The developers had just picked a query to
use as the "status" indicator and not given much thought to it -- just
selecting all rows from some table. This table happened to be one of the
main tables in the database, and while the query worked fine initially,
in the longer run this table grew so large that just the status queries
swamped the database server (and to some extent, the application server,
and the network connecting the two).
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


------------------------------

Date: Sun, 14 Mar 2004 14:07:38 +0100
From: Vetle Roeim <vetro@online.no>
Subject: Re: oracle socket creation
Message-Id: <m38yi3d1b9.fsf@quimby.dirtyhack.org>

* Juha Laiho
[...]
>
> Vetle Roeim <vetro@online.no> said:
>
> As for using an arbitary query for finding out the database status, I
> have a slight horror story. The developers had just picked a query to
> use as the "status" indicator and not given much thought to it -- just
> selecting all rows from some table. This table happened to be one of the
> main tables in the database, and while the query worked fine initially,
> in the longer run this table grew so large that just the status queries
> swamped the database server (and to some extent, the application server,
> and the network connecting the two).

  I was assuming the OP knew what he was doing, but you have an
  excellent point, of course. :)


-- 
#!/usr/bin/vr


------------------------------

Date: Sun, 14 Mar 2004 08:53:34 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Splitting filenames to extract a string
Message-Id: <i4V4c.4344$KO3.31144@attbi_s02>

nj_perl_newbie wrote:

> so that I don't get this:
> 2004-02-24 15:25:53 *  Now getting username
> 2004-02-24 15:25:53 *  Username is:  for . 
> 2004-02-24 15:25:53 *  Username is:  for .. 

You're not testing the result of your split().

> sub get_username {
>    141
>    142    &log_entry($logfh, "Now getting username") if $debug;
>    143
>    144    opendir(DIR,"$dir") or die "Error $! opening directory.";
>    145      my(@filenames) = readdir(DIR);
>    146    foreach (@filenames) {
>    147       my ($first,undef) = split(/\./, $_ );
>    148       my $username = $first;
>    149      &log_entry($logfh, "Username is: $username for $_ ") if $debug;
>    150    }
>    151    close(DIR);
>    152   }

142: Function calls do not need an ampersand (&) prefix.
144: Don't put double quotes where they are not needed.
144: Include $dir in error message.
151: Use closedir() not close(), move up to where readdir() is complete.
147: The undef is not needed.
148: Do you really need this?  Could use $username in line 147 instead.
149: Function calls do not need an ampersand prefix.
149: You need to test if the split() returned any data.

sub get_username {
   log_entry($logfh, "Now getting username") if $debug;
   opendir(DIR,$dir) or die "Error $! opening directory '$dir'.";
   my(@filenames) = readdir(DIR);
   closedir(DIR);
   foreach (@filenames) {
     my ($first) = split(/\./, $_ );
     if ($first) {
       log_entry($logfh, "Username is: $username for $_ ") if $debug;
     }
   }

	-Joe



------------------------------

Date: 14 Mar 2004 09:19:30 GMT
From: Roel van der Steen <roel-perl@st2x.net>
Subject: Re: Splitting filenames to extract a string
Message-Id: <slrnc588uk.phk.roel-perl@localhost.localdomain>

On Sun, 14 Mar 2004 at 08:53 GMT, Joe Smith wrote:
> nj_perl_newbie wrote:
>> so that I don't get this:
>> 2004-02-24 15:25:53 *  Now getting username
>> 2004-02-24 15:25:53 *  Username is:  for . 
>> 2004-02-24 15:25:53 *  Username is:  for .. 
> 
<snip> 
> sub get_username {
>    log_entry($logfh, "Now getting username") if $debug;
>    opendir(DIR,$dir) or die "Error $! opening directory '$dir'.";
>    my(@filenames) = readdir(DIR);
>    closedir(DIR);
>    foreach (@filenames) {
>      my ($first) = split(/\./, $_ );
           ^^^^^^
>      if ($first) {
           ^^^^^^
>        log_entry($logfh, "Username is: $username for $_ ") if $debug;
>      }
>    }

That should be: $username


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6256
***************************************


home help back first fref pref prev next nref lref last post